1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Core\Entity;
4:
5: use Salient\Contract\Container\ServiceAwareInterface;
6: use Salient\Contract\Core\Exception\InvalidDataException;
7: use Salient\Contract\Core\Provider\ProviderAwareInterface;
8: use Salient\Contract\Core\Provider\ProviderContextAwareInterface;
9: use Salient\Contract\Core\Provider\ProviderContextInterface;
10: use Salient\Contract\Core\Provider\ProviderInterface;
11: use Salient\Contract\HasConformity;
12:
13: /**
14: * @api
15: *
16: * @template TProvider of ProviderInterface
17: * @template TContext of ProviderContextInterface
18: *
19: * @extends ProviderAwareInterface<TProvider>
20: * @extends ProviderContextAwareInterface<TContext>
21: */
22: interface Providable extends
23: ProviderAwareInterface,
24: ProviderContextAwareInterface,
25: ServiceAwareInterface,
26: HasConformity
27: {
28: /**
29: * Get an instance from an array on behalf of a provider
30: *
31: * Values in `$data` are applied as per {@see Constructible::construct()}.
32: *
33: * @param mixed[] $data
34: * @param TContext $context
35: * @return static
36: * @throws InvalidDataException if values in `$data` do not satisfy the
37: * constructor or cannot be applied to the class.
38: */
39: public static function provide(
40: array $data,
41: ProviderContextInterface $context
42: );
43:
44: /**
45: * Get instances from arrays on behalf of a provider
46: *
47: * Values in `$data` arrays are applied as per {@see provide()}.
48: *
49: * @template TKey of array-key
50: *
51: * @param iterable<TKey,mixed[]> $data
52: * @param TContext $context
53: * @param Providable::* $conformity
54: * @return iterable<TKey,static>
55: * @throws InvalidDataException if values in `$data` arrays do not satisfy
56: * the constructor or cannot be applied to the class.
57: */
58: public static function provideMultiple(
59: iterable $data,
60: ProviderContextInterface $context,
61: int $conformity = Providable::CONFORMITY_NONE
62: ): iterable;
63:
64: /**
65: * Called after provider data is applied to the object
66: */
67: public function postLoad(): void;
68: }
69: