Code Duplication    Length = 26-27 lines in 3 locations

src/Paraunit/Parser/ErrorParser.php 1 location

@@ 7-33 (lines=27) @@
4
5
use Paraunit\Process\ProcessResultInterface;
6
7
class ErrorParser implements ProcessOutputParserChainElementInterface
8
{
9
    const ERROR_REGEX = '/(?:There (?:was|were) \d+ errors?:\n\n)((?:.|\n)+)(?:\n--|FAILURES)/U';
10
11
    /**
12
     * @param ProcessResultInterface $process
13
     *
14
     * @return bool True if chain should continue
15
     */
16
    public function parseAndContinue(ProcessResultInterface $process)
17
    {
18
        $errorsBlob = array();
19
        preg_match(self::ERROR_REGEX, $process->getOutput(), $errorsBlob);
20
21
        if (isset($errorsBlob[1])) {
22
            $errors = preg_split('/^\d+\) /m', $errorsBlob[1]);
23
            // il primo è sempre vuoto a causa dello split
24
            unset($errors[0]);
25
26
            foreach ($errors as $singleError) {
27
                $process->addError(trim($singleError));
28
            }
29
        }
30
31
        return true;
32
    }
33
}
34

src/Paraunit/Parser/FailureParser.php 1 location

@@ 7-32 (lines=26) @@
4
5
use Paraunit\Process\ProcessResultInterface;
6
7
class FailureParser implements ProcessOutputParserChainElementInterface
8
{
9
    const FAILURE_REGEX = '/(?:There (?:was|were) \d+ failures?:\n\n)((?:.|\n)+)(?=\nFAILURES)/';
10
11
    /**
12
     * @param ProcessResultInterface $process
13
     *
14
     * @return bool True if chain should continue
15
     */
16
    public function parseAndContinue(ProcessResultInterface $process)
17
    {
18
        $failuresBlob = array();
19
        preg_match(self::FAILURE_REGEX, $process->getOutput(), $failuresBlob);
20
        if (isset($failuresBlob[1])) {
21
            $failures = preg_split('/^\d+\) /m', $failuresBlob[1]);
22
            // il primo è sempre vuoto a causa dello split
23
            unset($failures[0]);
24
25
            foreach ($failures as $singleFailure) {
26
                $process->addFailure(trim($singleFailure));
27
            }
28
        }
29
30
        return true;
31
    }
32
}
33

src/Paraunit/Parser/WarningParser.php 1 location

@@ 7-33 (lines=27) @@
4
5
use Paraunit\Process\ProcessResultInterface;
6
7
class WarningParser implements ProcessOutputParserChainElementInterface
8
{
9
    const WARNING_REGEX = '/(?:There (?:was|were) \d+ warnings?:\n\n)((?:.|\n)+)(?:\n--|FAILURES|WARNINGS)/U';
10
11
    /**
12
     * @param ProcessResultInterface $process
13
     *
14
     * @return bool True if chain should continue
15
     */
16
    public function parseAndContinue(ProcessResultInterface $process)
17
    {
18
        $warningsBlob = array();
19
        preg_match(self::WARNING_REGEX, $process->getOutput(), $warningsBlob);
20
21
        if (isset($warningsBlob[1])) {
22
            $warnings = preg_split('/^\d+\) /m', $warningsBlob[1]);
23
            // il primo è sempre vuoto a causa dello split
24
            unset($warnings[0]);
25
26
            foreach ($warnings as $singleWarning) {
27
                $process->addWarning(trim($singleWarning));
28
            }
29
        }
30
31
        return true;
32
    }
33
}
34