vendor/fig/link-util/src/GenericLinkProvider.php line 8

Open in your IDE?
  1. <?php
  2. namespace Fig\Link;
  3. use Psr\Link\EvolvableLinkProviderInterface;
  4. use Psr\Link\LinkInterface;
  5. class GenericLinkProvider implements EvolvableLinkProviderInterface
  6. {
  7. use EvolvableLinkProviderTrait;
  8. /**
  9. * Constructs a new link provider.
  10. *
  11. * @param LinkInterface[] $links
  12. * Optionally, specify an initial set of links for this provider.
  13. * Note that the keys of the array will be ignored.
  14. */
  15. public function __construct(array $links = [])
  16. {
  17. // This block will throw a type error if any item isn't a LinkInterface, by design.
  18. array_filter($links, fn(LinkInterface $item) => true);
  19. $hashes = array_map('spl_object_hash', $links);
  20. $this->links = array_combine($hashes, $links);
  21. }
  22. }