Code Duplication    Length = 14-20 lines in 2 locations

src/CommandProcessor.php 1 location

@@ 94-113 (lines=20) @@
91
        }
92
    }
93
94
    public function validateRunAndAlter(
95
        $names,
96
        $commandCallback,
97
        $args,
98
        AnnotationData $annotationData
99
    ) {
100
        // Validators return any object to signal a validation error;
101
        // if the return an array, it replaces the arguments.
102
        $validated = $this->hookManager()->validateArguments($names, $args, $annotationData);
103
        if (is_object($validated)) {
104
            return $validated;
105
        }
106
        if (is_array($validated)) {
107
            $args = $validated;
108
        }
109
110
        // Run the command, alter the results, and then handle output and status
111
        $result = $this->runCommandCallback($commandCallback, $args);
112
        return $this->processResults($names, $result, $args, $annotationData);
113
    }
114
115
    public function processResults($names, $result, $args, $annotationData)
116
    {

src/Hooks/HookManager.php 1 location

@@ 173-186 (lines=14) @@
170
        }
171
    }
172
173
    public function validateArguments($names, $args, AnnotationData $annotationData)
174
    {
175
        $validators = $this->getValidators($names, $annotationData);
176
        foreach ($validators as $validator) {
177
            $validated = $this->callValidator($validator, $args, $annotationData);
178
            if (is_object($validated)) {
179
                return $validated;
180
            }
181
            if (is_array($validated)) {
182
                $args = $validated;
183
            }
184
        }
185
        return $args;
186
    }
187
188
    /**
189
     * Process result and decide what to do with it.