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