Code Duplication    Length = 23-23 lines in 2 locations

src/Validation.php 1 location

@@ 56-78 (lines=23) @@
53
     * @param bool $break_when_error
54
     * @return bool
55
     */
56
    public function run($break_when_error = false) : bool
57
    {
58
        /** @var Field $field */
59
        foreach ($this->fields as $field) {
60
            if (!$field->isValid($this->language)) {
61
                $this->status = false;
62
                $this->errors[$field->getName()] = $field->getErrors();
63
64
                /**
65
                 * break when there is any field error
66
                 */
67
                if ($break_when_error) {
68
                    break;
69
                }
70
            }
71
        }
72
73
        if (empty($this->errors)) {
74
            $this->status = true;
75
        }
76
77
        return $this->status;
78
    }
79
80
    /**
81
     * @return array

src/Field.php 1 location

@@ 69-91 (lines=23) @@
66
     * @param bool $break_when_error
67
     * @return bool
68
     */
69
    public function isValid(Language $language, $break_when_error = false) : bool
70
    {
71
        /** @var \PluginSimpleValidate\Contracts\Rule $rule */
72
        foreach ($this->rules as $ruleName => $rule) {
73
            if (!$rule->isValid($language, $this->value)) {
74
                $this->status = false;
75
                $this->errors[] = $rule->getError();
76
77
                /**
78
                 * break when there is any rule error
79
                 */
80
                if ($break_when_error === true) {
81
                    break;
82
                }
83
            }
84
        }
85
86
        if (empty($this->errors)) {
87
            $this->status = true;
88
        }
89
90
        return $this->status;
91
    }
92
93
    /**
94
     * @return string