1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Contract\Core; |
4: | |
5: | /** |
6: | * Has one-to-one and one-to-many relationships with other classes implementing |
7: | * the same interface |
8: | */ |
9: | interface Relatable |
10: | { |
11: | /** |
12: | * Get an array that maps property names to relationships |
13: | * |
14: | * Example: |
15: | * |
16: | * ```php |
17: | * <?php |
18: | * public static function getRelationships(): array |
19: | * { |
20: | * return [ |
21: | * 'CreatedBy' => [Cardinality::ONE_TO_ONE => User::class], |
22: | * 'Tags' => [Cardinality::ONE_TO_MANY => Tag::class], |
23: | * ]; |
24: | * } |
25: | * ``` |
26: | * |
27: | * @return array<string,array<Cardinality::*,class-string<Relatable>>> |
28: | * Property name => relationship type => target class |
29: | */ |
30: | public static function getRelationships(): array; |
31: | } |
32: |