|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Iris\Transfer\Tracking; |
|
4
|
|
|
|
|
5
|
|
|
use Iris\Transfer\Base; |
|
6
|
|
|
use Iris\Validator\AbstractValidator; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @SuppressWarnings(PHPMD.UnusedPrivateField) |
|
10
|
|
|
* @method string getPartnerCode() |
|
11
|
|
|
* @method string getVentureOrderNumber() |
|
12
|
|
|
* @method int getVentureOrderItemId() |
|
13
|
|
|
* @method AbstractTracking setPartnerCode(string $partnerCode) |
|
14
|
|
|
* @method AbstractTracking setVentureOrderNumber(string $ventureOrderNumber) |
|
15
|
|
|
* @method AbstractTracking setVentureOrderItemId(int $ventureOrderItemId) |
|
16
|
|
|
*/ |
|
17
|
|
|
abstract class AbstractTracking extends Base |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var int |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $ventureOrderItemId; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $partnerCode; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $ventureOrderNumber; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var AbstractValidator |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $validator; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return string |
|
41
|
|
|
*/ |
|
42
|
3 |
|
public function getName() |
|
43
|
|
|
{ |
|
44
|
3 |
|
$path = explode('\\', get_called_class()); |
|
45
|
|
|
|
|
46
|
3 |
|
return array_pop($path); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Validates the data |
|
51
|
|
|
* |
|
52
|
|
|
* @abstract |
|
53
|
|
|
* @access public |
|
54
|
|
|
* @return true | false |
|
55
|
|
|
*/ |
|
56
|
1 |
|
public function isValid() |
|
57
|
|
|
{ |
|
58
|
1 |
|
return $this->getValidator($this->getName())->isValid($this); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns validation errors |
|
63
|
|
|
* |
|
64
|
|
|
* @abstract |
|
65
|
|
|
* @access public |
|
66
|
|
|
* @return array |
|
67
|
|
|
*/ |
|
68
|
1 |
|
public function getErrors() |
|
69
|
|
|
{ |
|
70
|
1 |
|
return $this->getValidator($this->getName())->getErrors(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param string $name |
|
75
|
|
|
* @return AbstractValidator |
|
76
|
|
|
* @throws \RuntimeException |
|
77
|
|
|
*/ |
|
78
|
4 |
|
public function getValidator($name) |
|
79
|
|
|
{ |
|
80
|
4 |
|
if (!$this->validator) { |
|
81
|
2 |
|
$className = '\Iris\Validator\\' . $name; |
|
82
|
|
|
|
|
83
|
2 |
|
if (!class_exists($className)) { |
|
84
|
1 |
|
throw new \RuntimeException("Validator {$className} doesn't exists"); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
1 |
|
$this->validator = new $className(); |
|
88
|
1 |
|
} |
|
89
|
|
|
|
|
90
|
3 |
|
return $this->validator; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param AbstractValidator $validator |
|
95
|
|
|
* @return AbstractTracking |
|
96
|
|
|
*/ |
|
97
|
2 |
|
public function setValidator(AbstractValidator $validator) |
|
98
|
|
|
{ |
|
99
|
2 |
|
$this->validator = $validator; |
|
100
|
|
|
|
|
101
|
2 |
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|