1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Core\Provider;
4:
5: use Salient\Contract\Container\ServiceAwareInterface;
6: use Salient\Contract\Core\ListConformity;
7: use Salient\Contract\Iterator\FluentIteratorInterface;
8:
9: /**
10: * Serviced by a provider
11: *
12: * @template TProvider of ProviderInterface
13: * @template TContext of ProviderContextInterface
14: *
15: * @extends ProviderAwareInterface<TProvider>
16: * @extends ProviderContextAwareInterface<TContext>
17: */
18: interface Providable extends
19: ProviderAwareInterface,
20: ServiceAwareInterface,
21: ProviderContextAwareInterface
22: {
23: /**
24: * Create an instance of the class from an array on behalf of a provider
25: *
26: * @param mixed[] $data
27: * @param TProvider $provider
28: * @param TContext|null $context
29: * @return static
30: */
31: public static function provide(
32: array $data,
33: ProviderInterface $provider,
34: ?ProviderContextInterface $context = null
35: );
36:
37: /**
38: * Create instances of the class from arrays on behalf of a provider
39: *
40: * @param iterable<array-key,mixed[]> $list
41: * @param TProvider $provider
42: * @param ListConformity::* $conformity
43: * @param TContext|null $context
44: * @return FluentIteratorInterface<array-key,static>
45: */
46: public static function provideMultiple(
47: iterable $list,
48: ProviderInterface $provider,
49: int $conformity = ListConformity::NONE,
50: ?ProviderContextInterface $context = null
51: ): FluentIteratorInterface;
52:
53: /**
54: * Called after data from the provider has been applied to the object
55: */
56: public function postLoad(): void;
57: }
58: