1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the reva2/jsonapi. |
4
|
|
|
* |
5
|
|
|
* (c) Sergey Revenko <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Reva2\JsonApi\Decoders\Mapping; |
13
|
|
|
|
14
|
|
|
use Reva2\JsonApi\Contracts\Decoders\Mapping\PropertyMetadataInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Property metadata |
18
|
|
|
* |
19
|
|
|
* @package Reva2\JsonApi\Decoders\Mapping |
20
|
|
|
* @author Sergey Revenko <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class PropertyMetadata extends GenericMetadata implements PropertyMetadataInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
* @internal |
27
|
|
|
*/ |
28
|
|
|
public $propertyName; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
* @internal |
33
|
|
|
*/ |
34
|
|
|
public $setter; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
* @internal |
39
|
|
|
*/ |
40
|
|
|
public $dataType; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var null|string|array |
44
|
|
|
* @internal |
45
|
|
|
*/ |
46
|
|
|
public $dataTypeParams; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Constructor |
50
|
|
|
* |
51
|
|
|
* @param string $property |
52
|
|
|
* @param string $className |
53
|
|
|
*/ |
54
|
1 |
|
public function __construct($property, $className) |
55
|
|
|
{ |
56
|
1 |
|
parent::__construct($className); |
57
|
|
|
|
58
|
1 |
|
$this->propertyName = $property; |
59
|
1 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @inheritdoc |
63
|
|
|
*/ |
64
|
1 |
|
public function getPropertyName() |
65
|
|
|
{ |
66
|
1 |
|
return $this->propertyName; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @inheritdoc |
71
|
|
|
*/ |
72
|
1 |
|
public function getSetter() |
73
|
|
|
{ |
74
|
1 |
|
return $this->setter; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Sets property setter |
79
|
|
|
* |
80
|
|
|
* @param string|null $setter |
81
|
|
|
* @return $this |
82
|
|
|
*/ |
83
|
1 |
|
public function setSetter($setter = null) { |
84
|
1 |
|
$this->setter = $setter; |
85
|
|
|
|
86
|
1 |
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Returns property data type |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
1 |
|
public function getDataType() |
95
|
|
|
{ |
96
|
1 |
|
return $this->dataType; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Sets property data type |
101
|
|
|
* |
102
|
|
|
* @param string $dataType |
103
|
|
|
* @return $this |
104
|
|
|
*/ |
105
|
1 |
|
public function setDataType($dataType) |
106
|
|
|
{ |
107
|
1 |
|
$this->dataType = $dataType; |
108
|
|
|
|
109
|
1 |
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Returns additional data type params |
114
|
|
|
* |
115
|
|
|
* @return array|null|string |
116
|
|
|
*/ |
117
|
1 |
|
public function getDataTypeParams() |
118
|
|
|
{ |
119
|
1 |
|
return $this->dataTypeParams; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Sets additional data type params |
124
|
|
|
* |
125
|
|
|
* @param array|null|string $dataTypeParams |
126
|
|
|
* @return $this |
127
|
|
|
*/ |
128
|
1 |
|
public function setDataTypeParams($dataTypeParams = null) |
129
|
|
|
{ |
130
|
1 |
|
$this->dataTypeParams = $dataTypeParams; |
131
|
|
|
|
132
|
1 |
|
return $this; |
133
|
|
|
} |
134
|
|
|
} |