Tagged Questions
1
vote
0answers
16 views
Improvement of my php code
Hi guys,
I wrote a class with this functions. Can I improve my code performance in the bottom of the function? I don't like the while loops :D
Thank you for all answers.
public function ...
1
vote
1answer
22 views
Can I do something better in that code? And improvements?
Hi guys, simple question!
Can I do something better with the code I wrote.
It's running problem less. It's just a snippet of a library I wrote.
Thank you for all answers!
<?php
/*
* ...
0
votes
1answer
42 views
Should a User class only contain attributes and no methods apart from getters/setters?
I'm trying to improve my OOP code and I think my User class is becoming way too fat.
In my program a user has rights over "lists". Read, Write, Update, Delete.
So I made a User class
class User
{
...
8
votes
0answers
204 views
Thoughts on my brain fart interpreter?
Had some free time this weekend and I hacked together a small Brainfuck interpreter, with the sole intention of explaining PHP's flavour of OO to a friend. This is a bit over-engineered on purpose, ...
2
votes
1answer
81 views
First steps with PHP OOP
I am learning OOP using PHP5 and I wrote two simple classes for receive data of database using dependency injection pattern and render a grid with Twig.
Please, if is possible, take a look and give ...
1
vote
1answer
42 views
Using static for class default properties
I have made a class for generating html form elements:
class input
{
public $tag = 'input', $type = 'text', $customClass, $name;
public function __construct(array $cfg){
if ( ...
3
votes
3answers
182 views
PHP Simple OOP Class
I am still learning OOP and I need a little help, I don't really know how to properly make this not look so terrible.
Any thoughts?
<?php
class Noti {
public static $app;
public static ...
4
votes
2answers
259 views
Validation Class - Feedback Welcome!
I have written a Validation and Form class in PHP.
Validation class allow you to define the rules of each field and a error message.
Form class allow you to get a error message and also allow you ...
3
votes
1answer
490 views
How to improve Try…Catch Block for PDO?
I have written a PDO wrapper and a class file like a model. So far, it's looking so good! I am just confuse where I should put Try...Catch block - Would it be better to place in PDO wrapper ...
5
votes
2answers
120 views
When an object has different representations… what's the OO pattern?
I've an AbstractMessage object (a hierarchy, actually). It represents a small text message and can be sent using different transport methods: HTTP, REST and a "mailer" transport. Each transport relies ...
1
vote
1answer
277 views
PHP Config Class
I'm working on a config class for PHP, where I can easily bring in config options. Any improvements/suggestions are appreciated.
Example usage:
echo Config::get('database.host');
// Returns: ...
1
vote
1answer
177 views
PHP Lazy loading with __get - yay or nay?
I have my own PHP MVC framework that I'm iteratively developing (i.e. adding a feature when I have the time). I'm trying to keep it to the best practices I can, while still adding the most in terms of ...
2
votes
3answers
109 views
PHP spl_autoload_{x} class, reviews welcome
Having spent years writing procedural PHP (albeit with a moderate understanding of OOP from Java) I took the plunge and have attempted to write an autload class for my PHP applications.
I do have a ...
3
votes
1answer
275 views
How to convert my classes to Dependency injection?
I am still learning to develop my skills in OOP.
It uses a combination of the factory and its real singletons?
As I did more research, I have realized this design pattern is bad because of global ...
2
votes
1answer
377 views
OOP MySQL connection class
Under sage from another CR post I'm crafting an OOP MySQL connection/query class. Nothing new, but a place to start plying OOP PHP. Here is the current design,what would aid speed and portability?
...