Code Duplication    Length = 50-50 lines in 2 locations

src/Rules/Generic/AndOperator.php 1 location

@@ 29-78 (lines=50) @@
26
/**
27
 * @package Limoncello\Validation
28
 */
29
final class AndOperator extends BaseRule
30
{
31
    /**
32
     * @var RuleInterface
33
     */
34
    private $primary;
35
36
    /**
37
     * @var RuleInterface
38
     */
39
    private $secondary;
40
41
    /**
42
     * @param RuleInterface $primary
43
     * @param RuleInterface $secondary
44
     */
45
    public function __construct(RuleInterface $primary, RuleInterface $secondary)
46
    {
47
        $this->primary   = $primary;
48
        $this->secondary = $secondary;
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function toBlock(): ExecutionBlockInterface
55
    {
56
        return new AndBlock(
57
            $this->getPrimary()->setParent($this)->toBlock(),
58
            $this->getSecondary()->setParent($this)->toBlock(),
59
            $this->getStandardProperties()
60
        );
61
    }
62
63
    /**
64
     * @return RuleInterface
65
     */
66
    public function getPrimary(): RuleInterface
67
    {
68
        return $this->primary;
69
    }
70
71
    /**
72
     * @return RuleInterface
73
     */
74
    public function getSecondary(): RuleInterface
75
    {
76
        return $this->secondary;
77
    }
78
}
79

src/Rules/Generic/OrOperator.php 1 location

@@ 29-78 (lines=50) @@
26
/**
27
 * @package Limoncello\Validation
28
 */
29
final class OrOperator extends BaseRule
30
{
31
    /**
32
     * @var RuleInterface
33
     */
34
    private $primary;
35
36
    /**
37
     * @var RuleInterface
38
     */
39
    private $secondary;
40
41
    /**
42
     * @param RuleInterface $primary
43
     * @param RuleInterface $secondary
44
     */
45
    public function __construct(RuleInterface $primary, RuleInterface $secondary)
46
    {
47
        $this->primary   = $primary;
48
        $this->secondary = $secondary;
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function toBlock(): ExecutionBlockInterface
55
    {
56
        return new OrBlock(
57
            $this->getPrimary()->setParent($this)->toBlock(),
58
            $this->getSecondary()->setParent($this)->toBlock(),
59
            $this->getStandardProperties()
60
        );
61
    }
62
63
    /**
64
     * @return RuleInterface
65
     */
66
    public function getPrimary(): RuleInterface
67
    {
68
        return $this->primary;
69
    }
70
71
    /**
72
     * @return RuleInterface
73
     */
74
    public function getSecondary(): RuleInterface
75
    {
76
        return $this->secondary;
77
    }
78
}
79