public function __construct(SetInterface $builders)
 {
     if ((string) $builders->type() !== CreateBuilderInterface::class) {
         throw new InvalidArgumentException();
     }
     $this->builders = $builders;
 }
Exemplo n.º 2
0
 public function __construct(SetInterface $persisters)
 {
     if ((string) $persisters->type() !== PersisterInterface::class) {
         throw new InvalidArgumentException();
     }
     $this->persisters = $persisters;
 }
Exemplo n.º 3
0
 /**
  * {@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));
     });
 }
Exemplo n.º 4
0
 /**
  * {@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;
 }
Exemplo n.º 5
0
 /**
  * @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);
     });
 }