* @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:----lamhh+OYVytidrZgfgTI40zCqX71mg/uR3Gc7eUBa1FrP0HwAPkSn1EFII9F8LU7FLLZgkpGTGEt6ydwPjLP6ZMamrMuBlP2yBkwylqeL5CtkJBSHYfCSW6Y3vAv+g8YiDbrMW4zllsDSSLMPvSXVrLJ0BWK7xIcxxCREAUjrFglYko44HPzhdbeuMVO+hxo0AHgJUD06rWwhnRhjktwtgcmcT+65SQVPf6rCyUEn08mbWvL1sWDWklF6urhOdjzT3I/Eek/gsecbEXV8X8/WtfT8KPcmF8mPf9jnyLgDDS8eEhvCQaiKV/MgYAjyCk2JrfnzmOU5A8QJTAZL5/cFvsaKX48lHndokGQ3jnFSG8YEt/vwP1lRZUO31F/15/P/Ragz2qOrkcZXEgW1b3vOgqEu5koFi1+8zQgibI7EW2ck5FJoNDAAB131pXD9gCr/gT1K0r5smGGZjsOXBbJCUz+ZjB9DvAzVDvARVOjerrfguLW0FafmHJ/Dps6tbXrKqNDdynu4/ow8TW1p27mue3n7XBcxnnlZtDuXipk768OgqmDxQ6tgKKgC1Rx4zJKqV6XqOIdQwgl4t8jcnDvH2XlUDgdfHF5t6HWtsWEvGrufPP7Vc6wvW0yGNbcsl8ESdLgPoOm2zPY2yz1+Dxwrs0w7hpujqtSBI0Mv5oRXJc=----ATTACHMENT:----NTg3ODUwNTcxMjMzMDkzMyAzNDYyODkyMDYzNTkzNzgwIDk1MDkxNjE3OTc0NzUwMDQ=