Skip to content

Commit 3552c4b

Browse files
committed
chore: revert lint fix to main version
1 parent 1aa5516 commit 3552c4b

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

app/ModelSerializers/SerializerRegistry.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?php
2-
namespace App\ModelSerializers;
1+
<?php namespace App\ModelSerializers;
32
/**
43
* Copyright 2019 OpenStack Foundation
54
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,12 +41,10 @@ final class SerializerRegistry
4241
*/
4342
private static $instance;
4443

45-
const SerializerType_Public = 'PUBLIC';
44+
const SerializerType_Public = 'PUBLIC';
4645
const SerializerType_Private = 'PRIVATE';
4746

48-
private function __clone()
49-
{
50-
}
47+
private function __clone(){}
5148

5249
/**
5350
* @var IResourceServerContext
@@ -115,19 +112,17 @@ private function __construct()
115112
* @param string $type
116113
* @return IModelSerializer
117114
*/
118-
public function getSerializer($object, $type = self::SerializerType_Public)
119-
{
120-
if (is_null($object))
121-
return null;
122-
123-
$class = class_basename(is_string($object) ? $object : get_class($object));
124-
if (!isset($this->registry[$class]))
125-
throw new \InvalidArgumentException('Serializer not found for ' . $class);
115+
public function getSerializer($object, $type = self::SerializerType_Public){
116+
if(is_null($object)) return null;
117+
$reflect = new ReflectionClass($object);
118+
$class = $reflect->getShortName();
119+
if(!isset($this->registry[$class]))
120+
throw new \InvalidArgumentException('Serializer not found for '.$class);
126121

127122
$serializer_class = $this->registry[$class];
128123

129-
if (is_array($serializer_class)) {
130-
if (!isset($serializer_class[$type]))
124+
if(is_array($serializer_class)){
125+
if(!isset($serializer_class[$type]))
131126
throw new \InvalidArgumentException(sprintf('Serializer not found for %s , type %s', $class, $type));
132127
$serializer_class = $serializer_class[$type];
133128
}

0 commit comments

Comments
 (0)