|
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\Xml\Validator\VoidedValidator; |
|
12
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class Voided |
|
16
|
|
|
* @package Greenter\Model\Voided |
|
17
|
|
|
*/ |
|
18
|
|
View Code Duplication |
class Voided |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
use VoidedValidator; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @Assert\NotBlank() |
|
24
|
|
|
* @Assert\Length(max="3") |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $correlativo; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @Assert\Date() |
|
31
|
|
|
* @var \DateTime |
|
32
|
|
|
*/ |
|
33
|
|
|
private $fecGeneracion; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @Assert\NotBlank() |
|
37
|
|
|
* @Assert\Date() |
|
38
|
|
|
* @var \DateTime |
|
39
|
|
|
*/ |
|
40
|
|
|
private $fecComunicacion; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @Assert\Valid() |
|
44
|
|
|
* @var VoidedDetail[] |
|
45
|
|
|
*/ |
|
46
|
|
|
private $details; |
|
47
|
|
|
|
|
48
|
14 |
|
public function __construct() |
|
49
|
|
|
{ |
|
50
|
14 |
|
$this->fecGeneracion = new \DateTime(); |
|
51
|
14 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return string |
|
55
|
|
|
*/ |
|
56
|
6 |
|
public function getCorrelativo() |
|
57
|
|
|
{ |
|
58
|
6 |
|
return $this->correlativo; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param string $correlativo |
|
63
|
|
|
* @return Voided |
|
64
|
|
|
*/ |
|
65
|
14 |
|
public function setCorrelativo($correlativo) |
|
66
|
|
|
{ |
|
67
|
14 |
|
$this->correlativo = $correlativo; |
|
68
|
14 |
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return \DateTime |
|
73
|
|
|
*/ |
|
74
|
6 |
|
public function getFecGeneracion() |
|
75
|
|
|
{ |
|
76
|
6 |
|
return $this->fecGeneracion; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param \DateTime $fecGeneracion |
|
81
|
|
|
* @return Voided |
|
82
|
|
|
*/ |
|
83
|
14 |
|
public function setFecGeneracion($fecGeneracion) |
|
84
|
|
|
{ |
|
85
|
14 |
|
$this->fecGeneracion = $fecGeneracion; |
|
86
|
14 |
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return \DateTime |
|
91
|
|
|
*/ |
|
92
|
6 |
|
public function getFecComunicacion() |
|
93
|
|
|
{ |
|
94
|
6 |
|
return $this->fecComunicacion; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param \DateTime $fecComunicacion |
|
99
|
|
|
* @return Voided |
|
100
|
|
|
*/ |
|
101
|
14 |
|
public function setFecComunicacion($fecComunicacion) |
|
102
|
|
|
{ |
|
103
|
14 |
|
$this->fecComunicacion = $fecComunicacion; |
|
104
|
14 |
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return VoidedDetail[] |
|
109
|
|
|
*/ |
|
110
|
8 |
|
public function getDetails() |
|
111
|
|
|
{ |
|
112
|
8 |
|
return $this->details; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @param VoidedDetail[] $details |
|
117
|
|
|
* @return Voided |
|
118
|
|
|
*/ |
|
119
|
14 |
|
public function setDetails($details) |
|
120
|
|
|
{ |
|
121
|
14 |
|
$this->details = $details; |
|
122
|
14 |
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Get FileName without extension. |
|
127
|
|
|
* |
|
128
|
|
|
* @param string $ruc Ruc de la Empresa. |
|
129
|
|
|
* @return string |
|
130
|
|
|
*/ |
|
131
|
4 |
|
public function getFileName($ruc) |
|
132
|
|
|
{ |
|
133
|
|
|
$parts = [ |
|
134
|
4 |
|
$ruc, |
|
135
|
4 |
|
'RA', |
|
136
|
4 |
|
$this->getFecComunicacion()->format('Ymd'), |
|
137
|
4 |
|
$this->getCorrelativo(), |
|
138
|
4 |
|
]; |
|
139
|
|
|
|
|
140
|
4 |
|
return join('-', $parts); |
|
141
|
|
|
} |
|
142
|
|
|
} |
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.