|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
|
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
|
6
|
|
|
* For the information of copyright and license you should read the file |
|
7
|
|
|
* LICENSE which is distributed with this source code. |
|
8
|
|
|
* Para a informação dos direitos autorais e de licença você deve ler o arquivo |
|
9
|
|
|
* LICENSE que é distribuído com este código-fonte. |
|
10
|
|
|
* Para obtener la información de los derechos de autor y la licencia debe leer |
|
11
|
|
|
* el archivo LICENSE que se distribuye con el código fuente. |
|
12
|
|
|
* For more information, see <http://www.g1mr.com/>. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Gpupo\NetshoesSdk\Entity\Product\Sku; |
|
16
|
|
|
|
|
17
|
|
|
use DateTime; |
|
18
|
|
|
use DateTimeZone; |
|
19
|
|
|
use Gpupo\CommonSdk\Entity\EntityAbstract; |
|
20
|
|
|
use Gpupo\CommonSdk\Entity\EntityInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @method float getPriceFrom() Acesso a priceFrom |
|
24
|
|
|
* @method setPriceFrom(float $priceFrom) Define priceFrom |
|
25
|
|
|
* @method float getPriceTo() Acesso a priceTo |
|
26
|
|
|
* @method setPriceTo(float $priceTo) Define priceTo |
|
27
|
|
|
* @method string getDateInit() Acesso a dateInit |
|
28
|
|
|
* @method setDateInit(string $dateInit) Define dateInit |
|
29
|
|
|
* @method string getDateEnd() Acesso a dateEnd |
|
30
|
|
|
* @method setDateEnd(string $dateEnd) Define dateEnd |
|
31
|
|
|
*/ |
|
32
|
|
|
class PriceSchedule extends EntityAbstract implements EntityInterface |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @codeCoverageIgnore |
|
36
|
|
|
*/ |
|
37
|
|
|
public function getSchema() |
|
38
|
|
|
{ |
|
39
|
|
|
return [ |
|
40
|
|
|
'priceFrom' => 'number', |
|
41
|
|
|
'priceTo' => 'number', |
|
42
|
|
|
'dateInit' => 'string', |
|
43
|
|
|
'dateEnd' => 'string', |
|
44
|
|
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
7 |
|
protected function setUp() |
|
48
|
|
|
{ |
|
49
|
7 |
|
$this->setOptionalSchema(['priceFrom', 'dateEnd']); |
|
50
|
7 |
|
} |
|
51
|
|
|
|
|
52
|
8 |
|
protected function dateFormat($string) |
|
53
|
|
|
{ |
|
54
|
8 |
|
$timezone = new DateTimeZone('UTC'); |
|
55
|
8 |
|
$datetime = new DateTime($string, $timezone); |
|
56
|
|
|
|
|
57
|
8 |
|
return $datetime->format('c'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
6 |
|
public function setDateInit($string) |
|
61
|
|
|
{ |
|
62
|
6 |
|
return parent::setDateInit($this->dateFormat($string)); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
public function setDateEnd($string) |
|
66
|
|
|
{ |
|
67
|
1 |
|
return parent::setDateEnd($this->dateFormat($string)); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
5 |
|
public function toArray() |
|
71
|
|
|
{ |
|
72
|
5 |
|
$d = parent::getDateInit(); |
|
|
|
|
|
|
73
|
|
|
|
|
74
|
5 |
|
if (empty($d)) { |
|
75
|
5 |
|
$this->setDateInit(''); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
5 |
|
return parent::toArray(); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.