Fork me on GitHub

Dependency Injection service


A service which is to be injected in Jaxon classes can first be defined as an interface.

namespace Service;

interface ExampleInterface
{
    public function message($isCaps);
    public function color($name);
}

Then, there will be a class which implements the interface

namespace Service;

class Example implements ExampleInterface
{
    public function message($isCaps)
    {
        return ($isCaps) ? 'HELLO WORLD!!!!' : 'Hello World!!!!';
    }

    public function color($name)
    {
        return $name;
    }
}