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