@@ -40,7 +40,9 @@ |
||
| 40 | 40 | public function getJSON(): ?array |
| 41 | 41 | { |
| 42 | 42 | $data = json_decode($this->result, true); |
| 43 | - if (!is_array($data)) return null; |
|
| 43 | + if (!is_array($data)) { |
|
| 44 | + return null; |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | return $data; |
| 46 | 48 | } |
@@ -19,7 +19,9 @@ |
||
| 19 | 19 | public static function inst(Connector $connector, string $service): ?ApiService |
| 20 | 20 | { |
| 21 | 21 | $service = strtolower($service); |
| 22 | - if (!array_key_exists($service, ClassMap::SERVICES)) return null; |
|
| 22 | + if (!array_key_exists($service, ClassMap::SERVICES)) { |
|
| 23 | + return null; |
|
| 24 | + } |
|
| 23 | 25 | |
| 24 | 26 | $cls = ClassMap::SERVICES[$service]; |
| 25 | 27 | return new $cls($connector); |
@@ -98,7 +98,9 @@ |
||
| 98 | 98 | { |
| 99 | 99 | $curl = $this->getClient()->curl_api($url, 'DELETE', $params); |
| 100 | 100 | |
| 101 | - if ($curl->isValid()) return true; |
|
| 101 | + if ($curl->isValid()) { |
|
| 102 | + return true; |
|
| 103 | + } |
|
| 102 | 104 | |
| 103 | 105 | throw new ApiException($curl->getError()); |
| 104 | 106 | } |
@@ -59,7 +59,9 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | public function Customer(): ?Customer |
| 61 | 61 | { |
| 62 | - if (!$this->CustomerID) return null; |
|
| 62 | + if (!$this->CustomerID) { |
|
| 63 | + return null; |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | /** @var Customer|null $customer */ |
| 65 | 67 | $customer = $this->getClient()->customers->fetch($this->CustomerID); |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | foreach ($list as $item) { |
| 44 | 44 | $obj = ObjectFactory::make($this->getClient(), $item); |
| 45 | - if (!$obj) continue; |
|
| 45 | + if (!$obj) { |
|
| 46 | + continue; |
|
| 47 | + } |
|
| 46 | 48 | |
| 47 | 49 | $this->_items[] = $obj; |
| 48 | 50 | } |
@@ -76,6 +78,8 @@ discard block |
||
| 76 | 78 | */ |
| 77 | 79 | public function first(): ?Model |
| 78 | 80 | { |
| 79 | - foreach ($this as $obj) return $obj; |
|
| 81 | + foreach ($this as $obj) { |
|
| 82 | + return $obj; |
|
| 83 | + } |
|
| 80 | 84 | } |
| 81 | 85 | } |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | public static function create(Connector $connector, string $model, array $data = []): Model |
| 22 | 22 | { |
| 23 | 23 | $model = strtolower($model); |
| 24 | - if (!array_key_exists($model, ClassMap::MODELS)) return new LifeboatModel($connector, $data); |
|
| 24 | + if (!array_key_exists($model, ClassMap::MODELS)) { |
|
| 25 | + return new LifeboatModel($connector, $data); |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | $cls = ClassMap::MODELS[$model]; |
| 27 | 29 | return new $cls($connector, $data); |
@@ -35,7 +37,9 @@ discard block |
||
| 35 | 37 | public static function make(Connector $connector, array $data): Model |
| 36 | 38 | { |
| 37 | 39 | $model = $data['model'] ?? ''; |
| 38 | - if (!$model) return new LifeboatModel($connector, $data); |
|
| 40 | + if (!$model) { |
|
| 41 | + return new LifeboatModel($connector, $data); |
|
| 42 | + } |
|
| 39 | 43 | return self::create($connector, $model, $data); |
| 40 | 44 | } |
| 41 | 45 | } |
@@ -6,7 +6,9 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | function lifeboat_date_formatter(string $date): ?DateTime |
| 8 | 8 | { |
| 9 | - if (!$date) return null; |
|
| 9 | + if (!$date) { |
|
| 10 | + return null; |
|
| 11 | + } |
|
| 10 | 12 | |
| 11 | 13 | try { |
| 12 | 14 | $date = new \DateTime($date . ' CET'); |
@@ -68,7 +68,9 @@ |
||
| 68 | 68 | |
| 69 | 69 | // Test the randomness |
| 70 | 70 | $generated = []; |
| 71 | - while (count($generated) < 100000) $generated[] = Utils::create_random_string(); |
|
| 71 | + while (count($generated) < 100000) { |
|
| 72 | + $generated[] = Utils::create_random_string(); |
|
| 73 | + } |
|
| 72 | 74 | $count = count($generated); |
| 73 | 75 | $unique = count(array_unique($generated)); |
| 74 | 76 | $random = 100 - ((100 / $count) * $unique); |
@@ -129,16 +129,22 @@ discard block |
||
| 129 | 129 | $response = $this->getClient()->curl_api($this->getURL(), 'GET', $data); |
| 130 | 130 | $data = ($response->isValid() && $response->isJSON()) ? $response->getJSON() : []; |
| 131 | 131 | |
| 132 | - if (empty($data)) throw new ApiException($response->getError()); |
|
| 132 | + if (empty($data)) { |
|
| 133 | + throw new ApiException($response->getError()); |
|
| 134 | + } |
|
| 133 | 135 | |
| 134 | 136 | $this->_max_items = (int) $data['available_items']; |
| 135 | 137 | |
| 136 | - if (empty($data['items'])) return $this->_items[$page] = []; |
|
| 138 | + if (empty($data['items'])) { |
|
| 139 | + return $this->_items[$page] = []; |
|
| 140 | + } |
|
| 137 | 141 | |
| 138 | 142 | |
| 139 | 143 | foreach ($data['items'] as $item) { |
| 140 | 144 | $obj = ObjectFactory::make($this->getClient(), $item); |
| 141 | - if (!$obj) continue; |
|
| 145 | + if (!$obj) { |
|
| 146 | + continue; |
|
| 147 | + } |
|
| 142 | 148 | |
| 143 | 149 | $this->_items[$page][] = $obj; |
| 144 | 150 | } |
@@ -153,7 +159,9 @@ discard block |
||
| 153 | 159 | */ |
| 154 | 160 | public function offsetGet($offset): ?ObjectResource |
| 155 | 161 | { |
| 156 | - foreach ($this as $i => $obj) if ($i === $offset) return $obj; |
|
| 162 | + foreach ($this as $i => $obj) { |
|
| 163 | + if ($i === $offset) return $obj; |
|
| 164 | + } |
|
| 157 | 165 | return null; |
| 158 | 166 | } |
| 159 | 167 | |
@@ -184,7 +192,9 @@ discard block |
||
| 184 | 192 | */ |
| 185 | 193 | public function offsetExists($offset): bool |
| 186 | 194 | { |
| 187 | - foreach ($this as $i => $obj) if ($offset === $i) return true; |
|
| 195 | + foreach ($this as $i => $obj) { |
|
| 196 | + if ($offset === $i) return true; |
|
| 197 | + } |
|
| 188 | 198 | return false; |
| 189 | 199 | } |
| 190 | 200 | |
@@ -240,6 +250,8 @@ discard block |
||
| 240 | 250 | */ |
| 241 | 251 | public function first(): ?Model |
| 242 | 252 | { |
| 243 | - foreach ($this as $obj) return $obj; |
|
| 253 | + foreach ($this as $obj) { |
|
| 254 | + return $obj; |
|
| 255 | + } |
|
| 244 | 256 | } |
| 245 | 257 | } |