Code Duplication    Length = 28-28 lines in 2 locations

src/Validation/Rules/ApiRulesTrait.php 1 location

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

src/Validation/Rules/RelationshipRulesTrait.php 1 location

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