Passed
Push — master ( 4c8245...5bb496 )
by Scott
02:18
created

DiffStart   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 20
loc 20
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 11 11 1
A isValid() 4 4 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace exussum12\CoverageChecker\DiffLineHandle\OldVersion;
3
4
use exussum12\CoverageChecker\DiffLineHandle;
5
6 View Code Duplication
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