/**
  * @param $filter
  */
 public function addFilter($filter)
 {
     if (is_null($this->filters)) {
         $this->initFiltersCollection();
     }
     $this->filters->append(Invokable::cast($filter));
 }
 /**
  * ServicesFactory constructor.
  */
 public function __construct()
 {
     // init collections
     $this->services = (new Collection())->restrictTo(ServiceSpecsInterface::class);
     $this->builders = (new Collection())->restrictTo(ServiceBuilderInterface::class);
     $this->injectors = new Collection();
     $this->instances = new Collection();
     // register annotations
     AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Inject.php');
     $this->annotationsReader = new AnnotationReader();
     // load default builders
     $this->builders->append(new ClassServiceBuilder(), new PrefabServiceBuilder());
 }
Example #3
0
 public function testNormalizerStack()
 {
     $collection = new Collection(['a', 'b', 'C']);
     $collection->addNormalizer(function (&$value) {
         $value = strtolower($value);
     });
     $collection->addNormalizer(function (&$value) {
         $value = '_' . strtolower($value) . '_';
     });
     $this->assertEquals('_a_', $collection[0]);
     $this->assertEquals('_b_', $collection[1]);
     $this->assertEquals('_c_', $collection[2]);
     $collection->append('D');
     $this->assertEquals('_d_', $collection[3]);
 }
Example #4
0
 /**
  * @param ...$content
  */
 public function append(...$content)
 {
     $this->content->append(...$content);
     return $this;
 }