@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | // autoloader |
15 | 15 | function PSFSAutoloader($class) |
16 | 16 | { |
17 | - Logger::log("Trying to load class {$class} with " . __FILE__); |
|
17 | + Logger::log("Trying to load class {$class} with ".__FILE__); |
|
18 | 18 | // it only autoload class into the Rain scope |
19 | 19 | if (str_contains($class, 'PSFS')) { |
20 | 20 | // Change order src |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
24 | 24 | |
25 | 25 | // filepath |
26 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
26 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
27 | 27 | |
28 | 28 | // require the file |
29 | 29 | if (file_exists($abs_path)) { |
30 | 30 | require_once $abs_path; |
31 | - } else { |
|
32 | - Logger::log("{$class} not loaded with " . __FILE__); |
|
31 | + }else { |
|
32 | + Logger::log("{$class} not loaded with ".__FILE__); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | return false; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $now = new \DateTime(); |
19 | 19 | $now->setTimezone(new \DateTimeZone(Config::getParam('project.timezone', 'Europe/Madrid'))); |
20 | 20 | $config = Config::getInstance()->dumpConfig(); |
21 | - $config[self::CACHE_VAR_TAG] = 'v' . $now->format('Ymd.His'); |
|
21 | + $config[self::CACHE_VAR_TAG] = 'v'.$now->format('Ymd.His'); |
|
22 | 22 | Config::save($config); |
23 | 23 | return $config[self::CACHE_VAR_TAG]; |
24 | 24 | } |
@@ -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 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * @return mixed |
134 | 134 | */ |
135 | - public function jsonSerialize(): array|string|null |
|
135 | + public function jsonSerialize(): array | string | null |
|
136 | 136 | { |
137 | 137 | return $this->toArray(); |
138 | 138 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return mixed |
173 | 173 | */ |
174 | 174 | protected function checkCastedValue($rawValue, $type) { |
175 | - if(null !== $rawValue) { |
|
175 | + if (null !== $rawValue) { |
|
176 | 176 | switch ($type) { |
177 | 177 | default: |
178 | 178 | case 'string': |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $value = (bool)$rawValue; |
192 | 192 | break; |
193 | 193 | } |
194 | - } else { |
|
194 | + }else { |
|
195 | 195 | $value = $rawValue; |
196 | 196 | } |
197 | 197 | return $value; |