Completed
Push — master ( 6a6c7b...f57853 )
by Sebastian
03:30
created

MinLength   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 36
loc 36
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 7 7 2
A __construct() 4 4 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
2
3
/**
4
 * Linna Filter
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2017, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types = 1);
11
12
namespace Linna\Filter\Rules;
13
14
use Linna\Filter\RuleInterface;
15
16
/**
17
 * Check maximum length.
18
 */
19 View Code Duplication
class MinLength implements RuleInterface
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...
20
{
21
    /**
22
     * @var string Received value.
23
     */
24
    private $received;
25
    
26
    /**
27
     * @var int Min allowed length.
28
     */
29
    private $minLength;
30
31
    /**
32
     * Class constructor.
33
     *
34
     * @param string $received
35
     * @param int $minLength
36
     */
37
    public function __construct(string $received, int $minLength)
38
    {
39
        $this->received = $received;
40
        $this->minLength = $minLength;
41
    }
42
43
    /**
44
     * Test.
45
     *
46
     * @return bool
47
     */
48
    public function test(): bool
49
    {
50
        if (strlen($this->received) > $this->minLength) {
51
            return true;
52
        }
53
54
        return false;
55
    }
56
}
57