* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class MemoryListing implements ListingInterface { /** @var array */ protected $routes; /** @var \PSX\Api\SpecificationInterface */ protected $specification; public function __construct() { $this->routes = []; $this->specification = new Specification( new ResourceCollection(), new Definitions() ); } /** * @inheritdoc */ public function getAvailableRoutes(FilterInterface $filter = null): iterable { if ($filter !== null) { return array_values(array_filter($this->routes, static function(Route $route) use ($filter){ return $filter->match($route->getPath()); })); } else { return $this->routes; } } /** * @inheritdoc */ public function find(string $path, ?string $version = null): ?SpecificationInterface { $resource = $this->specification->getResourceCollection()->get($path); if (!$resource instanceof Resource) { return null; } $collection = new ResourceCollection(); $collection->set($resource); return new Specification( $collection, $this->specification->getDefinitions() ); } /** * @inheritdoc */ public function findAll(?string $version = null, FilterInterface $filter = null): SpecificationInterface { if ($filter !== null) { return new Specification( $this->specification->getResourceCollection()->filter($filter), $this->specification->getDefinitions() ); } else { return $this->specification; } } /** * @param \PSX\Api\Listing\Route $route */ public function addRoute(Route $route) { $this->routes[] = $route; } /** * @param SpecificationInterface $specification */ public function addSpecification(SpecificationInterface $specification) { $this->specification->merge($specification); } } __halt_compiler();----SIGNATURE:----Vh5pFKvnDkzWgHRGqIlB/R5YBmb3XyVaQWBnXwudwca9swwg2b6tmQZ2vvsYHEIPPQjBvD5cmBI7PX+PbDSTiX+TFTrG/T22mkP0OgsqRJTYHIcg4l892s2DFVyKKLkmVE1FonPkrsJVSLKmHp0VBBz2bw2/d5SrbU9gdgoYH1I/LJD6ztTVgZU7yaQscjSkngHjrXZQjq/Jof/r2o3qgHDIqht7Tmv6eeq56zY/AuJtC1I6sJb9XDmpuxPeLac3epbLQx/G/PsLiiG32IcbfV/1xIPy4gUjWKh5Vf4Fs6hzfoB2WGEJFadEMgY3vxncmZ6xYRGZyurEmC/JFs4/Zn7B4TphXEo5DVDLZUGI80Gm6xsYDi7XK4YuLQIMHuS1bPMlsmss9xJb8xuZAnn6jopBN5xjPEWS0liJF74CM6d8EpUXhHdMdKAxvs7UmQfnUDoR09riDI9/vmPlKoAiQv4jd4wE5OC3/YlLqncF+mqHmBnPfmJWc+DxzdhMvZ/ZskpV7dyTSm4es5+6Qdh/yv5gz3fmTkHt3SRR9LmyDkDm1AhDomqPcMehz0cf1SFteblbpV31OnsY2ZeAohY8MgTY8KmOkph+uox4D60gdlwvgo0NSJxV7T2EILFd5t0As/rJDE6eSTxRUqNhQeKBvQuuJh5D4YVEe4JqEC2cp5M=----ATTACHMENT:----NzE2OTcxNTE2NTE2ODc2NSA4MTYxNDQyNzczNjQ2MDMyIDc1NDEyNjA1OTI4MDU4Njc=