maj
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Grav\Framework\Contracts\Relationships;
|
||||
|
||||
use ArrayAccess;
|
||||
use Grav\Framework\Contracts\Object\IdentifierInterface;
|
||||
|
||||
/**
|
||||
* Interface RelationshipIdentifierInterface
|
||||
*/
|
||||
interface RelationshipIdentifierInterface extends IdentifierInterface
|
||||
{
|
||||
/**
|
||||
* If identifier has meta.
|
||||
*
|
||||
* @return bool
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function hasIdentifierMeta(): bool;
|
||||
|
||||
/**
|
||||
* Get identifier meta.
|
||||
*
|
||||
* @return array<string,mixed>|ArrayAccess<string,mixed>
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getIdentifierMeta();
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Grav\Framework\Contracts\Relationships;
|
||||
|
||||
use Countable;
|
||||
use Grav\Framework\Contracts\Object\IdentifierInterface;
|
||||
use IteratorAggregate;
|
||||
use JsonSerializable;
|
||||
use Serializable;
|
||||
|
||||
/**
|
||||
* Interface Relationship
|
||||
*
|
||||
* @template T of IdentifierInterface
|
||||
* @template P of IdentifierInterface
|
||||
* @extends IteratorAggregate<string, T>
|
||||
*/
|
||||
interface RelationshipInterface extends Countable, IteratorAggregate, JsonSerializable, Serializable
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getType(): string;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function isModified(): bool;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getCardinality(): string;
|
||||
|
||||
/**
|
||||
* @return P
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getParent(): IdentifierInterface;
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string|null $type
|
||||
* @return bool
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function has(string $id, string $type = null): bool;
|
||||
|
||||
/**
|
||||
* @param T $identifier
|
||||
* @return bool
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function hasIdentifier(IdentifierInterface $identifier): bool;
|
||||
|
||||
/**
|
||||
* @param T $identifier
|
||||
* @return bool
|
||||
*/
|
||||
public function addIdentifier(IdentifierInterface $identifier): bool;
|
||||
|
||||
/**
|
||||
* @param T|null $identifier
|
||||
* @return bool
|
||||
*/
|
||||
public function removeIdentifier(IdentifierInterface $identifier = null): bool;
|
||||
|
||||
/**
|
||||
* @return iterable<T>
|
||||
*/
|
||||
public function getIterator(): iterable;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Grav\Framework\Contracts\Relationships;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use Iterator;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* Interface RelationshipsInterface
|
||||
*
|
||||
* @template T of \Grav\Framework\Contracts\Object\IdentifierInterface
|
||||
* @template P of \Grav\Framework\Contracts\Object\IdentifierInterface
|
||||
* @extends ArrayAccess<string,RelationshipInterface<T,P>>
|
||||
* @extends Iterator<string,RelationshipInterface<T,P>>
|
||||
*/
|
||||
interface RelationshipsInterface extends Countable, ArrayAccess, Iterator, JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function isModified(): bool;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getModified(): array;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function count(): int;
|
||||
|
||||
/**
|
||||
* @param string $offset
|
||||
* @return RelationshipInterface<T,P>|null
|
||||
*/
|
||||
public function offsetGet($offset): ?RelationshipInterface;
|
||||
|
||||
/**
|
||||
* @return RelationshipInterface<T,P>|null
|
||||
*/
|
||||
public function current(): ?RelationshipInterface;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function key(): string;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Grav\Framework\Contracts\Relationships;
|
||||
|
||||
use Grav\Framework\Contracts\Object\IdentifierInterface;
|
||||
|
||||
/**
|
||||
* Interface ToManyRelationshipInterface
|
||||
*
|
||||
* @template T of IdentifierInterface
|
||||
* @template P of IdentifierInterface
|
||||
* @template-extends RelationshipInterface<T,P>
|
||||
*/
|
||||
interface ToManyRelationshipInterface extends RelationshipInterface
|
||||
{
|
||||
/**
|
||||
* @param positive-int $pos
|
||||
* @return IdentifierInterface|null
|
||||
*/
|
||||
public function getNthIdentifier(int $pos): ?IdentifierInterface;
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string|null $type
|
||||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getIdentifier(string $id, string $type = null): ?IdentifierInterface;
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string|null $type
|
||||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getObject(string $id, string $type = null): ?object;
|
||||
|
||||
/**
|
||||
* @param iterable<T> $identifiers
|
||||
* @return bool
|
||||
*/
|
||||
public function addIdentifiers(iterable $identifiers): bool;
|
||||
|
||||
/**
|
||||
* @param iterable<T> $identifiers
|
||||
* @return bool
|
||||
*/
|
||||
public function replaceIdentifiers(iterable $identifiers): bool;
|
||||
|
||||
/**
|
||||
* @param iterable<T> $identifiers
|
||||
* @return bool
|
||||
*/
|
||||
public function removeIdentifiers(iterable $identifiers): bool;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Grav\Framework\Contracts\Relationships;
|
||||
|
||||
use Grav\Framework\Contracts\Object\IdentifierInterface;
|
||||
|
||||
/**
|
||||
* Interface ToOneRelationshipInterface
|
||||
*
|
||||
* @template T of IdentifierInterface
|
||||
* @template P of IdentifierInterface
|
||||
* @template-extends RelationshipInterface<T,P>
|
||||
*/
|
||||
interface ToOneRelationshipInterface extends RelationshipInterface
|
||||
{
|
||||
/**
|
||||
* @param string|null $id
|
||||
* @param string|null $type
|
||||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getIdentifier(string $id = null, string $type = null): ?IdentifierInterface;
|
||||
|
||||
/**
|
||||
* @param string|null $id
|
||||
* @param string|null $type
|
||||
* @return T|null
|
||||
* @phpstan-pure
|
||||
*/
|
||||
public function getObject(string $id = null, string $type = null): ?object;
|
||||
|
||||
/**
|
||||
* @param T|null $identifier
|
||||
* @return bool
|
||||
*/
|
||||
public function replaceIdentifier(IdentifierInterface $identifier = null): bool;
|
||||
}
|
||||
Reference in New Issue
Block a user