@@ -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 | } |