@@ -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 | } |
@@ -44,7 +44,9 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | public function getAPIChallenge(): string |
| 46 | 46 | { |
| 47 | - if (!$this->_api_challenge) $this->_api_challenge = Utils::create_random_string(128); |
|
| 47 | + if (!$this->_api_challenge) { |
|
| 48 | + $this->_api_challenge = Utils::create_random_string(128); |
|
| 49 | + } |
|
| 48 | 50 | return $this->_api_challenge; |
| 49 | 51 | } |
| 50 | 52 | |
@@ -107,11 +107,15 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $this->_max_items = (int) $data['available_items']; |
| 109 | 109 | |
| 110 | - if (empty($data['items'])) return $this->_items[$page] = []; |
|
| 110 | + if (empty($data['items'])) { |
|
| 111 | + return $this->_items[$page] = []; |
|
| 112 | + } |
|
| 111 | 113 | |
| 112 | 114 | foreach ($data['items'] as $item) { |
| 113 | 115 | $obj = ObjectFactory::make($this->getClient(), $item); |
| 114 | - if (!$obj) continue; |
|
| 116 | + if (!$obj) { |
|
| 117 | + continue; |
|
| 118 | + } |
|
| 115 | 119 | |
| 116 | 120 | $this->_items[$page][] = $obj; |
| 117 | 121 | } |
@@ -126,7 +130,9 @@ discard block |
||
| 126 | 130 | */ |
| 127 | 131 | public function offsetGet($offset): ?ObjectResource |
| 128 | 132 | { |
| 129 | - foreach ($this as $i => $obj) if ($i === $offset) return $obj; |
|
| 133 | + foreach ($this as $i => $obj) { |
|
| 134 | + if ($i === $offset) return $obj; |
|
| 135 | + } |
|
| 130 | 136 | return null; |
| 131 | 137 | } |
| 132 | 138 | |
@@ -157,7 +163,9 @@ discard block |
||
| 157 | 163 | */ |
| 158 | 164 | public function offsetExists($offset): bool |
| 159 | 165 | { |
| 160 | - foreach ($this as $i => $obj) if ($offset === $i) return true; |
|
| 166 | + foreach ($this as $i => $obj) { |
|
| 167 | + if ($offset === $i) return true; |
|
| 168 | + } |
|
| 161 | 169 | return false; |
| 162 | 170 | } |
| 163 | 171 | |
@@ -213,6 +221,8 @@ discard block |
||
| 213 | 221 | */ |
| 214 | 222 | public function first(): ?Model |
| 215 | 223 | { |
| 216 | - foreach ($this as $obj) return $obj; |
|
| 224 | + foreach ($this as $obj) { |
|
| 225 | + return $obj; |
|
| 226 | + } |
|
| 217 | 227 | } |
| 218 | 228 | } |
@@ -45,7 +45,9 @@ |
||
| 45 | 45 | public function __get(string $service): ?ApiService |
| 46 | 46 | { |
| 47 | 47 | $obj = ServiceFactory::inst($this, $service); |
| 48 | - if (!$obj) throw new BadMethodException("Service for `{$service}` does not exist"); |
|
| 48 | + if (!$obj) { |
|
| 49 | + throw new BadMethodException("Service for `{$service}` does not exist"); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | return $obj; |
| 51 | 53 | } |
@@ -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 | } |