Question

I recently asked a question regarding the resolution of dependencies between Unit of Work and Data Mapper classes: Dependency Injection and Unit of Work pattern - (which was answered by Gabor de Mooij - thx)

In PoEAA, Martin Fowler suggests using Separated Interface to manage these dependencies. My question is simple - is it actually possible to implement this pattern in PHP, or is it specific to Java interfaces? I've searched high and low and it's hard to find references to this pattern anywhere outside of PoEAA.

Was it helpful?

Solution

Yes, it is possible (why would you doubt that?). If you're looking for an example, you could check out the Cookie Pattern blog.

OTHER TIPS

Have you tried Google? First result:

http://www.ibm.com/developerworks/opensource/library/os-advphpobj/#N101E7

This essentially says to use an abstract class that acts like an interface.

Scrolling down a bit, it shows that you can do it interfaces

interface Exportable {
    public function export();
}

class OurNews extends ThirdPartyNews 
              implements Exportable {
    // ...
    function export() {
        print "OurNews export\n";
    }
}

class Dictionary implements Exportable, Iterator {
    function export() {
        //...
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top