Code Duplication    Length = 23-23 lines in 2 locations

src/Field.php 1 location

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

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