public function __construct(SetInterface $builders) { if ((string) $builders->type() !== CreateBuilderInterface::class) { throw new InvalidArgumentException(); } $this->builders = $builders; }
public function __construct(SetInterface $persisters) { if ((string) $persisters->type() !== PersisterInterface::class) { throw new InvalidArgumentException(); } $this->persisters = $persisters; }
/** * {@inheritdoc} */ public function build(SetInterface $identities, ServerRequestInterface $request, HttpResource $definition, SpecificationInterface $specification = null, Range $range = null) : MapInterface { if ((string) $identities->type() !== IdentityInterface::class) { throw new InvalidArgumentException(); } return $this->builders->reduce(new Map('string', HeaderInterface::class), function (MapInterface $carry, ListBuilderInterface $builder) use($identities, $request, $definition, $specification, $range) : MapInterface { return $carry->merge($builder->build($identities, $request, $definition, $specification, $range)); }); }
/** * {@inheritdoc} */ public function load(SetInterface $files) : MapInterface { if ((string) $files->type() !== 'string') { throw new InvalidArgumentException(); } $config = (new Processor())->processConfiguration(new Configuration(), $files->reduce([], function (array $carry, string $file) { $carry[] = Yaml::parse(file_get_contents($file)); return $carry; })); $directories = new Map('string', Directory::class); foreach ($config as $key => $value) { $directories = $directories->put($key, $this->loadDirectory($key, $value)); } return $directories; }
/** * @param SetInterface<UrlInterface> $urls * * @return SetInterface<UrlInterface> */ public function __invoke(SetInterface $urls) : SetInterface { if ((string) $urls->type() !== UrlInterface::class) { throw new InvalidArgumentException(); } return $urls->reduce(new Map('string', UrlInterface::class), function (Map $urls, UrlInterface $url) : Map { $string = (string) $url; if ($urls->contains($string)) { return $urls; } return $urls->put($string, $url); })->reduce(new Set(UrlInterface::class), function (Set $urls, string $string, UrlInterface $url) : Set { return $urls->add($url); }); }