8
8
* For the full copyright and license information, please view the LICENSE
9
9
* file that was distributed with this source code.
10
10
*/
11
+
11
12
namespace NilPortugues \Api \Mapping ;
12
13
13
14
use NilPortugues \Api \Mappings \ApiMapping ;
@@ -50,14 +51,14 @@ public static function fromClass($className)
50
51
$ className = '\\' .ltrim ($ className , '\\' );
51
52
if (!class_exists ($ className , true )) {
52
53
throw new MappingException (
53
- sprintf ('Provided class %s could not be loaded. ' , $ className )
54
+ \ sprintf ('Provided class %s could not be loaded. ' , $ className )
54
55
);
55
56
}
56
57
$ instance = new $ className ();
57
58
58
- if (!in_array (ApiMapping::class, class_implements ($ instance , true ))) {
59
+ if (!in_array (ApiMapping::class, \ class_implements ($ instance , true ))) {
59
60
throw new MappingException (
60
- sprintf ('Class %s must implement %s. ' , ltrim ($ className , '\\' ), ApiMapping::class)
61
+ \ sprintf ('Class %s must implement %s. ' , \ ltrim ($ className , '\\' ), ApiMapping::class)
61
62
);
62
63
}
63
64
@@ -70,11 +71,11 @@ public static function fromClass($className)
70
71
static ::URLS_KEY => $ instance ->getUrls (),
71
72
];
72
73
73
- if (in_array (HalJsonMapping::class, class_implements ($ instance , true ))) {
74
+ if (\ in_array (HalJsonMapping::class, \ class_implements ($ instance , true ))) {
74
75
$ mappedClass [static ::CURIES_KEY ] = $ instance ->getCuries ();
75
76
}
76
77
77
- if (in_array (JsonApiMapping::class, class_implements ($ instance , true ))) {
78
+ if (\ in_array (JsonApiMapping::class, \ class_implements ($ instance , true ))) {
78
79
$ mappedClass [static ::RELATIONSHIPS_KEY ] = $ instance ->getRelationships ();
79
80
}
80
81
@@ -167,10 +168,10 @@ protected static function setAliasedProperties(array &$mappedClass, Mapping $map
167
168
{
168
169
if (false === empty ($ mappedClass [static ::ALIASED_PROPERTIES_KEY ])) {
169
170
$ mapping ->setPropertyNameAliases ($ mappedClass [static ::ALIASED_PROPERTIES_KEY ]);
170
- foreach (array_keys ($ mapping ->getAliasedProperties ()) as $ propertyName ) {
171
- if (false === in_array ($ propertyName , static ::getClassProperties ($ className ), true )) {
171
+ foreach (\ array_keys ($ mapping ->getAliasedProperties ()) as $ propertyName ) {
172
+ if (false === \ in_array ($ propertyName , static ::getClassProperties ($ className ), true )) {
172
173
throw new MappingException (
173
- sprintf (
174
+ \ sprintf (
174
175
'Could not alias property %s in class %s because it does not exist. ' ,
175
176
$ propertyName ,
176
177
$ className
@@ -203,11 +204,11 @@ protected static function getClassProperties($className)
203
204
204
205
if ($ parentClass = $ ref ->getParentClass ()) {
205
206
$ parentPropsArr = static ::getClassProperties ($ parentClass ->getName ());
206
- if (count ($ parentPropsArr ) > 0 ) {
207
- $ properties = array_merge ($ parentPropsArr , $ properties );
207
+ if (\ count ($ parentPropsArr ) > 0 ) {
208
+ $ properties = \ array_merge ($ parentPropsArr , $ properties );
208
209
}
209
210
}
210
- static ::$ classProperties [$ className ] = array_keys ($ properties );
211
+ static ::$ classProperties [$ className ] = \ array_keys ($ properties );
211
212
}
212
213
213
214
return static ::$ classProperties [$ className ];
@@ -225,9 +226,9 @@ protected static function setHideProperties(array &$mappedClass, Mapping $mappin
225
226
if (false === empty ($ mappedClass [static ::HIDE_PROPERTIES_KEY ])) {
226
227
$ mapping ->setHiddenProperties ($ mappedClass [static ::HIDE_PROPERTIES_KEY ]);
227
228
foreach ($ mapping ->getHiddenProperties () as $ propertyName ) {
228
- if (false === in_array ($ propertyName , static ::getClassProperties ($ className ), true )) {
229
+ if (false === \ in_array ($ propertyName , static ::getClassProperties ($ className ), true )) {
229
230
throw new MappingException (
230
- sprintf (
231
+ \ sprintf (
231
232
'Could not hide property %s in class %s because it does not exist. ' ,
232
233
$ propertyName ,
233
234
$ className
@@ -249,9 +250,9 @@ protected static function setRelationships(array &$mappedClass, Mapping $mapping
249
250
{
250
251
if (!empty ($ mappedClass [static ::RELATIONSHIPS_KEY ])) {
251
252
foreach ($ mappedClass [static ::RELATIONSHIPS_KEY ] as $ propertyName => $ urls ) {
252
- if (false === in_array ($ propertyName , static ::getClassProperties ($ className ))) {
253
+ if (false === \ in_array ($ propertyName , static ::getClassProperties ($ className ))) {
253
254
throw new MappingException (
254
- sprintf (
255
+ \ sprintf (
255
256
'Could not find property %s in class %s because it does not exist. ' ,
256
257
$ propertyName ,
257
258
$ className
0 commit comments