Code Duplication    Length = 14-20 lines in 2 locations

src/CommandProcessor.php 1 location

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

src/Hooks/HookManager.php 1 location

@@ 252-265 (lines=14) @@
249
        }
250
    }
251
252
    public function validateArguments($names, $args, AnnotationData $annotationData)
253
    {
254
        $validators = $this->getValidators($names, $annotationData);
255
        foreach ($validators as $validator) {
256
            $validated = $this->callValidator($validator, $args, $annotationData);
257
            if (is_object($validated)) {
258
                return $validated;
259
            }
260
            if (is_array($validated)) {
261
                $args = $validated;
262
            }
263
        }
264
        return $args;
265
    }
266
267
    /**
268
     * Process result and decide what to do with it.