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

@@ 325-338 (lines=14) @@
322
        }
323
    }
324
325
    public function validateArguments($names, $args, AnnotationData $annotationData)
326
    {
327
        $validators = $this->getValidators($names, $annotationData);
328
        foreach ($validators as $validator) {
329
            $validated = $this->callValidator($validator, $args, $annotationData);
330
            if (is_object($validated)) {
331
                return $validated;
332
            }
333
            if (is_array($validated)) {
334
                $args = $validated;
335
            }
336
        }
337
        return $args;
338
    }
339
340
    /**
341
     * Process result and decide what to do with it.