Document   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 69
loc 69
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getType() 4 4 1
A setType() 4 4 1
A getNumber() 4 4 1
A setNumber() 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
namespace MrPrompt\ShipmentCommon\Base;
3
4
/**
5
 * Document
6
 *
7
 * @author Thiago Paes <[email protected]>
8
 */
9 View Code Duplication
class Document
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...
10
{
11
    /**
12
     * CPF - for individual
13
     *
14
     * @const int
15
     */
16
    const CPF = 1;
17
18
    /**
19
     * CNPJ - for Legal Entity
20
     *
21
     */
22
    const CNPJ = 2;
23
24
    /**
25
     * @var string
26
     */
27
    private $type = self::CPF;
28
29
    /**
30
     * @var int
31
     */
32
    private $number;
33
34
    /**
35
     * Constructor
36
     * 
37
     * @param int $type
38
     * @param int $number
39
     */
40 6
    public function __construct(int $type = self::CPF, int $number = 0)
41
    {
42 6
        $this->type = $type;
0 ignored issues
show
Documentation Bug introduced by
The property $type was declared of type string, but $type is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
43 6
        $this->number = $number;
44 6
    }
45
46
    /**
47
     * @return string
48
     */
49 1
    public function getType(): int
50
    {
51 1
        return $this->type;
52
    }
53
54
    /**
55
     * @param string $type
56
     */
57 1
    public function setType(int $type)
58
    {
59 1
        $this->type = $type;
0 ignored issues
show
Documentation Bug introduced by
The property $type was declared of type string, but $type is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
60 1
    }
61
62
    /**
63
     * @return mixed
64
     */
65 1
    public function getNumber(): int
66
    {
67 1
        return $this->number;
68
    }
69
70
    /**
71
     * @param mixed $number
72
     */
73 1
    public function setNumber(int $number)
74
    {
75 1
        $this->number = $number;
76 1
    }
77
}
78