1
vote
0answers
38 views

How to create a simple stateless cache class in PHP

i need to create a cache class to avoid making the same calculations more than needed. My idea was something really basic like class transient_cache { static private $cache = array(); static ...
0
votes
0answers
11 views

Is it acceptable for child classes to “break” parent class functionality? [migrated]

One of the devs that works with me is following the Open/Closed Principle to add functionality to a Model by extending from our framework ORM. class BaseModel extends ORM { ... } All our models ...
0
votes
2answers
79 views

PHP MVC simple sign up form review? Please be honest :)

I have tried to build my first MVC sign up form here is the code. Here is the user controller method register. public function register() { if($this->isPost()) { $user = new ...
1
vote
2answers
83 views

How to implement Publish-subscribe pattern in PHP?

I have two classes, Database and Logger. Database is responsible for handling SQL queries, and Logger logs messages to an external file. Whenever the database executes an SQL query, I want Logger to ...
3
votes
1answer
176 views

Optimize PHP Class

I'm looking for a better way to provide configuration options and improvements in general. I'm using the constructor injection pattern to get access to the Cache and Twitter class. $callback and ...
1
vote
1answer
97 views

Builder & decorator patterns together, am I doing this right?

Little background: payload is the representation of a message being send, using a specific transport. The builder pattern is used to build different representation (as array, or as a Swift_Message ...
1
vote
1answer
38 views

Thoughts on the testability of my use case interactor?

So here is a class that executes the CreateAPerson use case. It takes a request object (which is a simple data structure), validates the request, creates a new person, and then returns a response ...
3
votes
4answers
134 views

Refactoring a class hierarchy to remove subclasses

I have the following class inheritances hierarchy: First the abstract parent class: <?php abstract class SegmentParserAbstract{ /** @var ParserResult */ protected $_result; protected ...
4
votes
2answers
243 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 ...
5
votes
2answers
118 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 ...
3
votes
1answer
160 views

Tips for Making this Code Testable

So I'm writing an abstraction layer that wraps a telephony RESTful service for sending text messages and making phone calls. I should build this in such a way that the low-level provider, in this case ...
1
vote
2answers
231 views

Correct GenericDAO implementation?

I implemented a MVC Framework with Generic DAO and I would like know if is correct. I did not have developed yet the MySQLDAO. My controller class class ClienteController { public function ...
1
vote
1answer
205 views

What is the correct way to set up my classes in OOP programming in PHP?

Let me start with a little introduction. I am in the process of learning OOP in PHP. I have also researched Design Patterns but have not yet fully grasped the different types of concepts. I am at the ...
1
vote
1answer
146 views

Does this code follow loose coupling pattern or should be refactored/re-designed?

I've to adming i don't like this design. The main class (SMSHelper) is responsible of query a REST web service which in turn returns an XML string. This helper is going to return a new SMSCreditInfo ...
1
vote
1answer
58 views

contract validation and responsibility without exceptions in the constructor

my question is based on this "principles" do not throw exceptions in a constructor single responsibility / seperation of conerns use logic exceptions for broken contracts and runtime exceptions for ...

1 2
15 30 50 per page