@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | public function __construct($hydrate = true) |
19 | 19 | { |
20 | 20 | parent::__construct(); |
21 | - if($hydrate) { |
|
21 | + if ($hydrate) { |
|
22 | 22 | $this->fromArray(Request::getInstance()->getData()); |
23 | 23 | } |
24 | 24 | } |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | /** @var \ReflectionProperty $property */ |
47 | 47 | foreach ($properties as $property) { |
48 | 48 | $value = $property->getValue($this); |
49 | - if(is_object($value) && method_exists($value, 'toArray')) { |
|
49 | + if (is_object($value) && method_exists($value, 'toArray')) { |
|
50 | 50 | $dto[$property->getName()] = $value->toArray(); |
51 | - } else { |
|
51 | + }else { |
|
52 | 52 | $dto[$property->getName()] = $property->getValue($this); |
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
56 | - } catch (\Exception $e) { |
|
57 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
56 | + }catch (\Exception $e) { |
|
57 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
58 | 58 | } |
59 | 59 | return $dto; |
60 | 60 | } |
@@ -76,32 +76,32 @@ discard block |
||
76 | 76 | protected function parseDtoField(array $properties, $key, $value = null) { |
77 | 77 | $type = 'string'; |
78 | 78 | $is_array = false; |
79 | - if(array_key_exists($key, $properties)) { |
|
79 | + if (array_key_exists($key, $properties)) { |
|
80 | 80 | $type = $properties[$key]; |
81 | - if(preg_match('/(\[\]|Array)/i', $type)) { |
|
81 | + if (preg_match('/(\[\]|Array)/i', $type)) { |
|
82 | 82 | $type = preg_replace('/(\[\]|Array)/i', '', $type); |
83 | 83 | $is_array = true; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null; |
87 | - if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
88 | - if(null !== $value && is_array($value)) { |
|
89 | - if($is_array) { |
|
87 | + if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
88 | + if (null !== $value && is_array($value)) { |
|
89 | + if ($is_array) { |
|
90 | 90 | $this->$key = []; |
91 | - foreach($value as $data) { |
|
92 | - if(null !== $data && is_array($data)) { |
|
91 | + foreach ($value as $data) { |
|
92 | + if (null !== $data && is_array($data)) { |
|
93 | 93 | $dto = new $type(false); |
94 | 94 | $dto->fromArray($data); |
95 | 95 | array_push($this->$key, $dto); |
96 | 96 | } |
97 | 97 | } |
98 | - } else { |
|
98 | + }else { |
|
99 | 99 | $this->$key = new $type(false); |
100 | 100 | $this->$key->fromArray($value); |
101 | 101 | } |
102 | 102 | } |
103 | - } else { |
|
104 | - switch($type) { |
|
103 | + }else { |
|
104 | + switch ($type) { |
|
105 | 105 | default: |
106 | 106 | case 'string': |
107 | 107 | $this->$key = $value; |