Code Duplication    Length = 14-20 lines in 2 locations

src/CommandProcessor.php 1 location

@@ 78-97 (lines=20) @@
75
        }
76
    }
77
78
    public function validateRunAndAlter(
79
        $names,
80
        $commandCallback,
81
        $args,
82
        AnnotationData $annotationData
83
    ) {
84
        // Validators return any object to signal a validation error;
85
        // if the return an array, it replaces the arguments.
86
        $validated = $this->hookManager()->validateArguments($names, $args, $annotationData);
87
        if (is_object($validated)) {
88
            return $validated;
89
        }
90
        if (is_array($validated)) {
91
            $args = $validated;
92
        }
93
94
        // Run the command, alter the results, and then handle output and status
95
        $result = $this->runCommandCallback($commandCallback, $args);
96
        return $this->processResults($names, $result, $args, $annotationData);
97
    }
98
99
    public function processResults($names, $result, $args, $annotationData)
100
    {

src/Hooks/HookManager.php 1 location

@@ 146-159 (lines=14) @@
143
        $this->hooks[$name][self::EXTRACT_OUTPUT][] = $outputExtractor;
144
    }
145
146
    public function validateArguments($names, $args, AnnotationData $annotationData)
147
    {
148
        $validators = $this->getValidators($names, $annotationData);
149
        foreach ($validators as $validator) {
150
            $validated = $this->callValidator($validator, $args, $annotationData);
151
            if (is_object($validated)) {
152
                return $validated;
153
            }
154
            if (is_array($validated)) {
155
                $args = $validated;
156
            }
157
        }
158
        return $args;
159
    }
160
161
    /**
162
     * Process result and decide what to do with it.