ToManyRelationshipInterface.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php declare(strict_types=1);
  2. namespace Grav\Framework\Contracts\Relationships;
  3. use Grav\Framework\Contracts\Object\IdentifierInterface;
  4. /**
  5. * Interface ToManyRelationshipInterface
  6. *
  7. * @template T of IdentifierInterface
  8. * @template P of IdentifierInterface
  9. * @template-extends RelationshipInterface<T,P>
  10. */
  11. interface ToManyRelationshipInterface extends RelationshipInterface
  12. {
  13. /**
  14. * @param positive-int $pos
  15. * @return IdentifierInterface|null
  16. */
  17. public function getNthIdentifier(int $pos): ?IdentifierInterface;
  18. /**
  19. * @param string $id
  20. * @param string|null $type
  21. * @return T|null
  22. * @phpstan-pure
  23. */
  24. public function getIdentifier(string $id, string $type = null): ?IdentifierInterface;
  25. /**
  26. * @param string $id
  27. * @param string|null $type
  28. * @return T|null
  29. * @phpstan-pure
  30. */
  31. public function getObject(string $id, string $type = null): ?object;
  32. /**
  33. * @param iterable<T> $identifiers
  34. * @return bool
  35. */
  36. public function addIdentifiers(iterable $identifiers): bool;
  37. /**
  38. * @param iterable<T> $identifiers
  39. * @return bool
  40. */
  41. public function replaceIdentifiers(iterable $identifiers): bool;
  42. /**
  43. * @param iterable<T> $identifiers
  44. * @return bool
  45. */
  46. public function removeIdentifiers(iterable $identifiers): bool;
  47. }