Code Duplication    Length = 17-20 lines in 3 locations

src/DiffLineHandle/NewVersion/DiffStart.php 1 location

@@ 6-25 (lines=20) @@
3
4
use exussum12\CoverageChecker\DiffLineHandle;
5
6
class DiffStart extends DiffLineHandle
7
{
8
9
    public function handle($line)
10
    {
11
        $foundVariables = sscanf(
12
            $line,
13
            '@@ -%d,%d +%d,%d @@'
14
        );
15
16
        $newFrom = $foundVariables[2];
17
18
        $this->diffFileState->setCurrentPosition($newFrom - 1);
19
    }
20
21
    public function isValid($line)
22
    {
23
        return $line[0] == '@' && $line[1] == '@';
24
    }
25
}
26

src/DiffLineHandle/NewVersion/NewFile.php 1 location

@@ 6-22 (lines=17) @@
3
4
use exussum12\CoverageChecker\DiffLineHandle;
5
6
class NewFile extends DiffLineHandle
7
{
8
9
    public function handle($line)
10
    {
11
        $parsedLine = sscanf($line, '+++ %1s/%s');
12
        $currentFileName = $parsedLine[1];
13
        if ($currentFileName) {
14
            $this->diffFileState->setCurrentFile($currentFileName);
15
        }
16
    }
17
18
    public function isValid($line)
19
    {
20
        return $line[0] == '+' && $line[1] == '+';
21
    }
22
}
23

src/DiffLineHandle/OldVersion/DiffStart.php 1 location

@@ 6-25 (lines=20) @@
3
4
use exussum12\CoverageChecker\DiffLineHandle;
5
6
class DiffStart extends DiffLineHandle
7
{
8
9
    public function handle($line)
10
    {
11
        $foundVariables = sscanf(
12
            $line,
13
            '@@ -%d,%d +%d,%d @@'
14
        );
15
16
        $oldFrom = $foundVariables[0];
17
18
        $this->diffFileState->setCurrentPosition($oldFrom - 1);
19
    }
20
21
    public function isValid($line)
22
    {
23
        return $line[0] == '@' && $line[1] == '@';
24
    }
25
}
26