@@ -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 | } |
@@ -81,10 +81,14 @@ |
||
| 81 | 81 | $service = $this->getService(); |
| 82 | 82 | |
| 83 | 83 | if ($this->exists()) { |
| 84 | - if (!method_exists($service, 'update')) return $this; |
|
| 84 | + if (!method_exists($service, 'update')) { |
|
| 85 | + return $this; |
|
| 86 | + } |
|
| 85 | 87 | return $service->update($this->ID, $this->toArray()); |
| 86 | 88 | } else { |
| 87 | - if (!method_exists($service, 'create')) return $this; |
|
| 89 | + if (!method_exists($service, 'create')) { |
|
| 90 | + return $this; |
|
| 91 | + } |
|
| 88 | 92 | return $service->create($this->toArray()); |
| 89 | 93 | } |
| 90 | 94 | } |