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
|
|
|
* @var string|null |
50
|
|
|
* @internal |
51
|
|
|
*/ |
52
|
|
|
public $ormEntity; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Constructor |
56
|
|
|
* |
57
|
|
|
* @param string $property |
58
|
|
|
* @param string $className |
59
|
|
|
*/ |
60
|
5 |
|
public function __construct($property, $className) |
61
|
|
|
{ |
62
|
5 |
|
parent::__construct($className); |
63
|
|
|
|
64
|
5 |
|
$this->propertyName = $property; |
65
|
5 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @inheritdoc |
69
|
|
|
*/ |
70
|
5 |
|
public function getPropertyName() |
71
|
|
|
{ |
72
|
5 |
|
return $this->propertyName; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @inheritdoc |
77
|
|
|
*/ |
78
|
3 |
|
public function getSetter() |
79
|
|
|
{ |
80
|
3 |
|
return $this->setter; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Sets property setter |
85
|
|
|
* |
86
|
|
|
* @param string|null $setter |
87
|
|
|
* @return $this |
88
|
|
|
*/ |
89
|
2 |
|
public function setSetter($setter = null) { |
90
|
2 |
|
$this->setter = $setter; |
91
|
|
|
|
92
|
2 |
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Returns property data type |
97
|
|
|
* |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
3 |
|
public function getDataType() |
101
|
|
|
{ |
102
|
3 |
|
return $this->dataType; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Sets property data type |
107
|
|
|
* |
108
|
|
|
* @param string $dataType |
109
|
|
|
* @return $this |
110
|
|
|
*/ |
111
|
5 |
|
public function setDataType($dataType) |
112
|
|
|
{ |
113
|
5 |
|
$this->dataType = $dataType; |
114
|
|
|
|
115
|
5 |
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Returns additional data type params |
120
|
|
|
* |
121
|
|
|
* @return array|null|string |
122
|
|
|
*/ |
123
|
3 |
|
public function getDataTypeParams() |
124
|
|
|
{ |
125
|
3 |
|
return $this->dataTypeParams; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Sets additional data type params |
130
|
|
|
* |
131
|
|
|
* @param array|null|string $dataTypeParams |
132
|
|
|
* @return $this |
133
|
|
|
*/ |
134
|
5 |
|
public function setDataTypeParams($dataTypeParams = null) |
135
|
|
|
{ |
136
|
5 |
|
$this->dataTypeParams = $dataTypeParams; |
137
|
|
|
|
138
|
5 |
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @inheritdoc |
143
|
|
|
*/ |
144
|
1 |
|
public function getOrmEntityClass() |
145
|
|
|
{ |
146
|
1 |
|
return $this->ormEntity; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Sets name of ORM entity class |
151
|
|
|
* |
152
|
|
|
* @param string|null $entityClass |
153
|
|
|
* @return $this |
154
|
|
|
*/ |
155
|
5 |
|
public function setOrmEntityClass($entityClass = null) |
156
|
|
|
{ |
157
|
5 |
|
$this->ormEntity = $entityClass; |
158
|
|
|
|
159
|
5 |
|
return $this; |
160
|
|
|
} |
161
|
|
|
} |