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

FixedCG::compareLength()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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