Test Failed
Push — master ( 05d675...f4e7d7 )
by Giancarlos
04:02
created

Voided   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 162
Duplicated Lines 6.17 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCorrelativo() 0 4 1
A setCorrelativo() 0 5 1
A getFecGeneracion() 0 4 1
A setFecGeneracion() 0 5 1
A getFecComunicacion() 0 4 1
A setFecComunicacion() 0 5 1
A getCompany() 0 4 1
A setCompany() 0 5 1
A getDetails() 0 4 1
A setDetails() 0 5 1
A getName() 0 4 1
A getXmlId() 10 10 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
 * Created by PhpStorm.
4
 * User: Giansalex
5
 * Date: 15/07/2017
6
 * Time: 22:00
7
 */
8
9
namespace Greenter\Model\Voided;
10
11
use Greenter\Model\Company\Company;
12
use Greenter\Model\DocumentInterface;
13
use Greenter\Xml\Validator\VoidedValidator;
14
use Symfony\Component\Validator\Constraints as Assert;
15
16
/**
17
 * Class Voided
18
 * @package Greenter\Model\Voided
19
 */
20
class Voided implements DocumentInterface
21
{
22
    use VoidedValidator;
23
24
    /**
25
     * @Assert\NotBlank()
26
     * @Assert\Length(max="3")
27
     * @var string
28
     */
29
    private $correlativo;
30
31
    /**
32
     * Fecha de generación del documento dado de baja.
33
     *
34
     * @Assert\Date()
35
     * @var \DateTime
36
     */
37
    private $fecGeneracion;
38
39
    /**
40
     * Fecha de generación de la comunicación.
41
     *
42
     * @Assert\NotBlank()
43
     * @Assert\Date()
44
     * @var \DateTime
45
     */
46
    private $fecComunicacion;
47
48
    /**
49
     * @Assert\NotBlank()
50
     * @Assert\Valid()
51
     * @var Company
52
     */
53
    private $company;
54
55
    /**
56
     * @Assert\Valid()
57
     * @var VoidedDetail[]
58
     */
59
    private $details;
60
61
    public function __construct()
62
    {
63
        $this->fecGeneracion = new \DateTime();
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getCorrelativo()
70
    {
71
        return $this->correlativo;
72
    }
73
74
    /**
75
     * @param string $correlativo
76
     * @return Voided
77
     */
78
    public function setCorrelativo($correlativo)
79
    {
80
        $this->correlativo = $correlativo;
81
        return $this;
82
    }
83
84
    /**
85
     * @return \DateTime
86
     */
87
    public function getFecGeneracion()
88
    {
89
        return $this->fecGeneracion;
90
    }
91
92
    /**
93
     * @param \DateTime $fecGeneracion
94
     * @return Voided
95
     */
96
    public function setFecGeneracion($fecGeneracion)
97
    {
98
        $this->fecGeneracion = $fecGeneracion;
99
        return $this;
100
    }
101
102
    /**
103
     * @return \DateTime
104
     */
105
    public function getFecComunicacion()
106
    {
107
        return $this->fecComunicacion;
108
    }
109
110
    /**
111
     * @param \DateTime $fecComunicacion
112
     * @return Voided
113
     */
114
    public function setFecComunicacion($fecComunicacion)
115
    {
116
        $this->fecComunicacion = $fecComunicacion;
117
        return $this;
118
    }
119
120
    /**
121
     * @return Company
122
     */
123
    public function getCompany()
124
    {
125
        return $this->company;
126
    }
127
128
    /**
129
     * @param Company $company
130
     * @return Voided
131
     */
132
    public function setCompany($company)
133
    {
134
        $this->company = $company;
135
        return $this;
136
    }
137
138
    /**
139
     * @return VoidedDetail[]
140
     */
141
    public function getDetails()
142
    {
143
        return $this->details;
144
    }
145
146
    /**
147
     * @param VoidedDetail[] $details
148
     * @return Voided
149
     */
150
    public function setDetails($details)
151
    {
152
        $this->details = $details;
153
        return $this;
154
    }
155
156
    /**
157
     * Get FileName without extension.
158
     *
159
     * @return string
160
     */
161
    public function getName()
162
    {
163
        return $this->company->getRuc() . '-' . $this->getXmlId();
164
    }
165
166
    /**
167
     * Get Id XML.
168
     *
169
     * @return string
170
     */
171 View Code Duplication
    public function getXmlId()
0 ignored issues
show
Duplication introduced by
This method 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...
172
    {
173
        $parts = [
174
            'RA',
175
            $this->getFecComunicacion()->format('Ymd'),
176
            $this->getCorrelativo(),
177
        ];
178
179
        return join('-', $parts);
180
    }
181
}