@@ 29-56 (lines=28) @@ | ||
26 | /** |
|
27 | * @package Limoncello\Flute |
|
28 | */ |
|
29 | trait ApiRulesTrait |
|
30 | { |
|
31 | /** |
|
32 | * @param string $apiClass |
|
33 | * @param RuleInterface|null $next |
|
34 | * |
|
35 | * @return RuleInterface |
|
36 | */ |
|
37 | public static function readable(string $apiClass, RuleInterface $next = null): RuleInterface |
|
38 | { |
|
39 | $primary = new IsReadableViaApiRule($apiClass); |
|
40 | ||
41 | return $next === null ? $primary : new AndOperator($primary, $next); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * @param string $apiClass |
|
46 | * @param RuleInterface|null $next |
|
47 | * |
|
48 | * @return RuleInterface |
|
49 | */ |
|
50 | public static function readableAll(string $apiClass, RuleInterface $next = null): RuleInterface |
|
51 | { |
|
52 | $primary = new AreReadableViaApiRule($apiClass); |
|
53 | ||
54 | return $next === null ? $primary : new AndOperator($primary, $next); |
|
55 | } |
|
56 | } |
|
57 |
@@ 29-56 (lines=28) @@ | ||
26 | /** |
|
27 | * @package Limoncello\Flute |
|
28 | */ |
|
29 | trait RelationshipRulesTrait |
|
30 | { |
|
31 | /** |
|
32 | * @param string $type |
|
33 | * @param RuleInterface|null $next |
|
34 | * |
|
35 | * @return RuleInterface |
|
36 | */ |
|
37 | public static function toOneRelationship(string $type, RuleInterface $next = null): RuleInterface |
|
38 | { |
|
39 | $primary = new ToOneRelationshipTypeCheckerRule($type); |
|
40 | ||
41 | return $next === null ? $primary : new AndOperator($primary, $next); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * @param string $type |
|
46 | * @param RuleInterface|null $next |
|
47 | * |
|
48 | * @return RuleInterface |
|
49 | */ |
|
50 | public static function toManyRelationship(string $type, RuleInterface $next = null): RuleInterface |
|
51 | { |
|
52 | $primary = new ToManyRelationshipTypeCheckerRule($type); |
|
53 | ||
54 | return $next === null ? $primary : new AndOperator($primary, $next); |
|
55 | } |
|
56 | } |
|
57 |