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

@@ 197-210 (lines=14) @@
194
        }
195
    }
196
197
    public function validateArguments($names, $args, AnnotationData $annotationData)
198
    {
199
        $validators = $this->getValidators($names, $annotationData);
200
        foreach ($validators as $validator) {
201
            $validated = $this->callValidator($validator, $args, $annotationData);
202
            if (is_object($validated)) {
203
                return $validated;
204
            }
205
            if (is_array($validated)) {
206
                $args = $validated;
207
            }
208
        }
209
        return $args;
210
    }
211
212
    /**
213
     * Process result and decide what to do with it.