2
votes
1answer
72 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 ...
8
votes
0answers
209 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, ...
1
vote
2answers
124 views

Basic PHP comment form: what ways can I improve security, efficiency/cleanliness, or conventionality?

I am a programming novice. I've written this simple PHP script to run a very basic comment form and would appreciate any feedback, especially on these three topics: Efficiency (not sure the right ...
1
vote
1answer
86 views

wordpress - simple theme options in array

I am created a wordpress theme options using array, and it is working. There are 5 type of input text,textarea,checkbox,select and upload. Kindly check this function and give suggestion and tweks. ...
1
vote
1answer
102 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 ...
3
votes
4answers
137 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 ...
1
vote
1answer
77 views

PHP Random List

Gentlemen! So what I have here is a function who's main purpose is to check whether an attribute exists and if so add it to another list for a maximum of 3 entries. The first item in the list should ...
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 ...
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
1answer
92 views

Are these MySQL Abstraction Classes safe from SQL Injection? Can they be made safe?

I was looking at this website: http://www.devshed.com/c/a/MySQL/Creating-User-Models-in-PHP-and-MySQL/1/ and http://www.devshed.com/c/a/MySQL/Creating-User-Models-in-PHP-and-MySQL/2/ In the first ...
0
votes
2answers
189 views

PDO class design

I have the following class design for my PDO database access class. Please can someone confirm that this is good practice, or suggest improvements if necessary. Thanks. Database.php class db { ...
1
vote
1answer
147 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
104 views

PHP - Is this proper use of exceptions for error handling within classes?

I've searched plenty on this topic and have gotten a lot of good (but different) results. Some of the results weren't quite related and it does seem to be a matter of preference in the end, but I'm ...