Preffix   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A appliesTheRule() 5 5 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
 * ShouldPHP
4
 *
5
 * @author  Gabriel Jacinto <[email protected]>
6
 * @status  dev
7
 * @link    https://github.com/GabrielJMJ/ShouldPHP
8
 * @license MIT
9
 */
10
 
11
namespace Gabrieljmj\Should\Runner\Rule\Directory;
12
13
use Gabrieljmj\Should\Runner\Rule\Directory\AbstractDirectoryRule;
14
15 View Code Duplication
class Preffix extends AbstractDirectoryRule
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...
16
{
17
    /**
18
     * Files preffix
19
     *
20
     * @var string
21
     */
22
    private $preffix;
23
24
    /**
25
     * @param string $preffix
26
     */
27
    public function __construct($preffix)
28
    {
29
        $this->preffix = $preffix;
30
    }
31
32
    /**
33
     * Applies the rule
34
     *
35
     * @param string $file
36
     * @return boolean
37
     */
38
    protected function appliesTheRule($file)
39
    {
40
        $e = explode('\\', $file);
41
        return substr(end($e), 0, strlen($this->preffix)) === $this->preffix;
42
    }
43
}