@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function fetch(int $id): ?Order |
| 44 | 44 | { |
| 45 | 45 | /** @var Order|null $fetch */ |
| 46 | - $fetch = $this->_get('api/orders/order' . $id); |
|
| 46 | + $fetch = $this->_get('api/orders/order'.$id); |
|
| 47 | 47 | return $fetch; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function update(int $id, array $data): ?Order |
| 71 | 71 | { |
| 72 | 72 | /** @var Order|null $post */ |
| 73 | - $post = $this->_post('api/orders/order/' . $id, $data); |
|
| 73 | + $post = $this->_post('api/orders/order/'.$id, $data); |
|
| 74 | 74 | return $post; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -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); |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | $t = $this->getItems(); |
| 63 | 63 | $c = $this->count(); |
| 64 | 64 | |
| 65 | - return (function () use ($t, $c) { |
|
| 65 | + return (function() use ($t, $c) { |
|
| 66 | 66 | $i = 0; |
| 67 | 67 | |
| 68 | 68 | while ($i < $c) { |
@@ -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 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function fetch(int $id): ?CustomPage |
| 38 | 38 | { |
| 39 | 39 | /** @var CustomPage|null $fetch */ |
| 40 | - $fetch = $this->_get('api/pages/page' . $id); |
|
| 40 | + $fetch = $this->_get('api/pages/page'.$id); |
|
| 41 | 41 | return $fetch; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | public function update(int $id, array $data): ?CustomPage |
| 65 | 65 | { |
| 66 | 66 | /** @var CustomPage|null $post */ |
| 67 | - $post = $this->_post('api/pages/page/' . $id, $data); |
|
| 67 | + $post = $this->_post('api/pages/page/'.$id, $data); |
|
| 68 | 68 | return $post; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function fetch(int $id): ?Collection |
| 23 | 23 | { |
| 24 | 24 | /** @var Collection|null $fetch */ |
| 25 | - $fetch = $this->_get('api/collections/collection' . $id); |
|
| 25 | + $fetch = $this->_get('api/collections/collection'.$id); |
|
| 26 | 26 | return $fetch; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | public function update(int $id, array $data): ?Collection |
| 50 | 50 | { |
| 51 | 51 | /** @var Collection|null $post */ |
| 52 | - $post = $this->_post('api/collections/collection/' . $id, $data); |
|
| 52 | + $post = $this->_post('api/collections/collection/'.$id, $data); |
|
| 53 | 53 | return $post; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function delete(int $id): bool |
| 63 | 63 | { |
| 64 | - return $this->_delete('api/collections/collection/' . $id); |
|
| 64 | + return $this->_delete('api/collections/collection/'.$id); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -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 | } |
@@ -21,11 +21,11 @@ |
||
| 21 | 21 | public function __construct(string $_api_key, string $_api_secret, $_auth_domain = self::AUTH_DOMAIN) |
| 22 | 22 | { |
| 23 | 23 | if (!$_api_key) { |
| 24 | - throw new InvalidArgumentException(static::class . ' parameter 1 should be your api key'); |
|
| 24 | + throw new InvalidArgumentException(static::class.' parameter 1 should be your api key'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | if (!$_api_secret) { |
| 28 | - throw new InvalidArgumentException(static::class . ' parameter 2 should be your api secret'); |
|
| 28 | + throw new InvalidArgumentException(static::class.' parameter 2 should be your api secret'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $this->_api_key = $_api_key; |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | // Model or Object |
| 35 | 35 | if (!array_key_exists('field_name', $value)) { |
| 36 | 36 | $this->$field = ObjectFactory::make($client, $value); |
| 37 | - } else { |
|
| 37 | + }else { |
|
| 38 | 38 | // Has One Relation - Deprecated |
| 39 | 39 | $name = $value['field_name']; |
| 40 | 40 | $this->$name = $value['field_value']; |
| 41 | 41 | $this->$field = ObjectFactory::make($client, $value['object_data']); |
| 42 | 42 | } |
| 43 | - } else { |
|
| 43 | + }else { |
|
| 44 | 44 | // HasMany / ManyMany Relation |
| 45 | 45 | $list = []; |
| 46 | 46 | foreach ($value as $item) { |
| 47 | 47 | if (ArrayLib::is_associative($item)) { |
| 48 | 48 | $list[] = ObjectFactory::make($client, $item); |
| 49 | - } else { |
|
| 49 | + }else { |
|
| 50 | 50 | $list[] = $item; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | if ($model === static::class) return new $service($this->getClient()); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - throw new ErrorException("Could not determine which service to use for " . static::class); |
|
| 86 | + throw new ErrorException("Could not determine which service to use for ".static::class); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if ($this->exists()) { |
| 98 | 98 | if (!method_exists($service, 'update')) return $this; |
| 99 | 99 | return $service->update($this->ID, $this->toArray()); |
| 100 | - } else { |
|
| 100 | + }else { |
|
| 101 | 101 | if (!method_exists($service, 'create')) return $this; |
| 102 | 102 | return $service->create($this->toArray()); |
| 103 | 103 | } |
@@ -80,7 +80,9 @@ discard block |
||
| 80 | 80 | public function getService(): ApiService |
| 81 | 81 | { |
| 82 | 82 | foreach (ClassMap::SERVICE_MODEL as $service => $model) { |
| 83 | - if ($model === static::class) return new $service($this->getClient()); |
|
| 83 | + if ($model === static::class) { |
|
| 84 | + return new $service($this->getClient()); |
|
| 85 | + } |
|
| 84 | 86 | } |
| 85 | 87 | |
| 86 | 88 | throw new ErrorException("Could not determine which service to use for " . static::class); |
@@ -95,10 +97,14 @@ discard block |
||
| 95 | 97 | $service = $this->getService(); |
| 96 | 98 | |
| 97 | 99 | if ($this->exists()) { |
| 98 | - if (!method_exists($service, 'update')) return $this; |
|
| 100 | + if (!method_exists($service, 'update')) { |
|
| 101 | + return $this; |
|
| 102 | + } |
|
| 99 | 103 | return $service->update($this->ID, $this->toArray()); |
| 100 | 104 | } else { |
| 101 | - if (!method_exists($service, 'create')) return $this; |
|
| 105 | + if (!method_exists($service, 'create')) { |
|
| 106 | + return $this; |
|
| 107 | + } |
|
| 102 | 108 | return $service->create($this->toArray()); |
| 103 | 109 | } |
| 104 | 110 | } |
@@ -54,10 +54,10 @@ |
||
| 54 | 54 | { |
| 55 | 55 | $app = new App('id', 'secret', 'http://test.domain'); |
| 56 | 56 | $url = $app->getAuthURL('process.php', 'error.php', 'challenge'); |
| 57 | - $expect = 'http://test.domain/oauth/code?app_id=id&process_url=' . |
|
| 58 | - urlencode('process.php') . |
|
| 59 | - '&error_url=' . urlencode('error.php') . |
|
| 60 | - '&challenge=' . Utils::pack('challenge'); |
|
| 57 | + $expect = 'http://test.domain/oauth/code?app_id=id&process_url='. |
|
| 58 | + urlencode('process.php'). |
|
| 59 | + '&error_url='.urlencode('error.php'). |
|
| 60 | + '&challenge='.Utils::pack('challenge'); |
|
| 61 | 61 | |
| 62 | 62 | $this->assertEquals($expect, $url); |
| 63 | 63 | } |