Completed
Push — master ( e2d05f...edeffb )
by Vitaly
09:12
created

FixedCG   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 22
loc 22
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A compareLength() 7 7 1

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 declare(strict_types=1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 06.04.17 at 07:34
5
 */
6
namespace samsonframework\stringconditiontree\string;
7
8
/**
9
 * This class describes character group with fixed length.
10
 *
11
 * @author Vitaly Egorov <[email protected]>
12
 */
13 View Code Duplication
class FixedCG extends AbstractCharacterGroup
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /** string Character group matching regexp pattern matching group name */
16
    const PATTERN_GROUP = 'fixed';
17
18
    /** string Regular expression matching character group */
19
    const PATTERN_REGEXP = '[^{}]+';
20
21
    /** string Character group matching regexp pattern */
22
    const PATTERN = '(?<'.self::PATTERN_GROUP.'>'.self::PATTERN_REGEXP.')';
23
24
    /**
25
     * @inheritdoc
26
     */
27 3
    protected function compareLength(AbstractCharacterGroup $group): int
28
    {
29
        /**
30
         * Shorter fixed character group has higher priority
31
         */
32 3
        return $group->length <=> $this->length;
33
    }
34
}
35