Code Duplication    Length = 14-20 lines in 2 locations

src/CommandProcessor.php 1 location

@@ 110-129 (lines=20) @@
107
        }
108
    }
109
110
    public function validateRunAndAlter(
111
        $names,
112
        $commandCallback,
113
        $args,
114
        AnnotationData $annotationData
115
    ) {
116
        // Validators return any object to signal a validation error;
117
        // if the return an array, it replaces the arguments.
118
        $validated = $this->hookManager()->validateArguments($names, $args, $annotationData);
119
        if (is_object($validated)) {
120
            return $validated;
121
        }
122
        if (is_array($validated)) {
123
            $args = $validated;
124
        }
125
126
        // Run the command, alter the results, and then handle output and status
127
        $result = $this->runCommandCallback($commandCallback, $args);
128
        return $this->processResults($names, $result, $args, $annotationData);
129
    }
130
131
    public function processResults($names, $result, $args, $annotationData)
132
    {

src/Hooks/HookManager.php 1 location

@@ 312-325 (lines=14) @@
309
        }
310
    }
311
312
    public function validateArguments($names, $args, AnnotationData $annotationData)
313
    {
314
        $validators = $this->getValidators($names, $annotationData);
315
        foreach ($validators as $validator) {
316
            $validated = $this->callValidator($validator, $args, $annotationData);
317
            if (is_object($validated)) {
318
                return $validated;
319
            }
320
            if (is_array($validated)) {
321
                $args = $validated;
322
            }
323
        }
324
        return $args;
325
    }
326
327
    /**
328
     * Process result and decide what to do with it.