Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Imagine you have something like these "service" or "helper" provider interfaces/objects

Code Block
titlesomwheresomewhere.php
linenumberstrue
languagephp
<?php
interface ServiceLocatorInterface
{
    function get($name); //You call this to get your helper depending on argument
    function getByPattern($name);
}
class ServiceManager implements ServiceLocatorInterface
{
    function get($name) {
        return new $name; //simplest test example implementation
    }

    function getByPattern($name) {
        return new $name;
    }
}
$serviceManager = (new ServiceManager());

 
function globalFactoryFunction($param) {return new $param;}
 

...