@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct($hydrate = true) |
20 | 20 | { |
21 | 21 | parent::__construct(); |
22 | - if($hydrate) { |
|
22 | + if ($hydrate) { |
|
23 | 23 | $this->fromArray(Request::getInstance()->getData()); |
24 | 24 | } |
25 | 25 | } |
@@ -47,23 +47,23 @@ discard block |
||
47 | 47 | /** @var \ReflectionProperty $property */ |
48 | 48 | foreach ($properties as $property) { |
49 | 49 | $value = $property->getValue($this); |
50 | - if(is_object($value) && method_exists($value, 'toArray')) { |
|
50 | + if (is_object($value) && method_exists($value, 'toArray')) { |
|
51 | 51 | $dto[$property->getName()] = $value->toArray(); |
52 | - } elseif(is_array($value)) { |
|
53 | - foreach($value as &$arrValue) { |
|
54 | - if($arrValue instanceof Dto) { |
|
52 | + } elseif (is_array($value)) { |
|
53 | + foreach ($value as &$arrValue) { |
|
54 | + if ($arrValue instanceof Dto) { |
|
55 | 55 | $arrValue = $arrValue->toArray(); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | $dto[$property->getName()] = $value; |
59 | - } else { |
|
59 | + }else { |
|
60 | 60 | $type = InjectorHelper::extractVarType($property->getDocComment()); |
61 | 61 | $dto[$property->getName()] = $this->checkCastedValue($property->getValue($this), $type); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
65 | - } catch (\Exception $e) { |
|
66 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
65 | + }catch (\Exception $e) { |
|
66 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
67 | 67 | } |
68 | 68 | return $dto; |
69 | 69 | } |
@@ -86,26 +86,26 @@ discard block |
||
86 | 86 | protected function parseDtoField(array $properties, $key, $value = null) { |
87 | 87 | list($type, $isArray) = $this->extractTypes($properties, $key); |
88 | 88 | $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null; |
89 | - if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
90 | - if(null !== $value && is_array($value)) { |
|
91 | - if(!array_key_exists($type, $this->__cache)) { |
|
89 | + if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
90 | + if (null !== $value && is_array($value)) { |
|
91 | + if (!array_key_exists($type, $this->__cache)) { |
|
92 | 92 | $this->__cache[$type] = new $type(false); |
93 | 93 | } |
94 | - if($isArray) { |
|
94 | + if ($isArray) { |
|
95 | 95 | $this->$key = []; |
96 | - foreach($value as $data) { |
|
97 | - if(null !== $data && is_array($data)) { |
|
96 | + foreach ($value as $data) { |
|
97 | + if (null !== $data && is_array($data)) { |
|
98 | 98 | $dto = clone $this->__cache[$type]; |
99 | 99 | $dto->fromArray($data); |
100 | 100 | array_push($this->$key, $dto); |
101 | 101 | } |
102 | 102 | } |
103 | - } else { |
|
103 | + }else { |
|
104 | 104 | $this->$key = clone $this->__cache[$type]; |
105 | 105 | $this->$key->fromArray($value); |
106 | 106 | } |
107 | 107 | } |
108 | - } else { |
|
108 | + }else { |
|
109 | 109 | $this->castValue($key, $value, $type); |
110 | 110 | } |
111 | 111 | } |