public function assertOptionsContainsNoopInjector(Collection $options) { if ($options->isEmpty()) { throw new ExpectationFailedException('Options array is empty; no NoopInjector found!'); } $options = $options->toArray(); $injector = array_shift($options)->getInjector(); if (!$injector instanceof NoopInjector) { throw new ExpectationFailedException('Options array does not contain a NoopInjector!'); } }
/** * Is a given metadata value (extra.zf.*) valid? * * @param string $key Key to examine in metadata * @param array $metadata * @return bool */ private function metadataForKeyIsValid($key, array $metadata) { if (!isset($metadata[$key])) { return false; } if (is_string($metadata[$key])) { return $this->moduleIsValid($metadata[$key]); } if (!is_array($metadata[$key])) { return false; } return Collection::create($metadata[$key])->reduce(function ($valid, $value) { if (false === $valid) { return $valid; } return $this->moduleIsValid($value); }, null); }
/** * {@inheritDoc} */ public function remove($package, IOInterface $io) { $this->chain->each(function ($injector) use($package, $io) { $injector->remove($package, $io); }); }
/** * {@inheritDoc} */ public function discoveryExists($name) { return $this->chain->offsetExists($name); }
/** * Cache an injector for later use. * * @param Injector\InjectorInterface $injector * @return void */ private function cacheInjector(Injector\InjectorInterface $injector) { Collection::create($injector->getTypesAllowed())->reject(function ($type) { return isset($this->cachedInjectors[$type]); })->each(function ($type) use($injector) { $this->cachedInjectors[$type] = $injector; }); }