@@ -139,7 +139,7 @@ |
||
139 | 139 | public function describe($model, $relationships) |
140 | 140 | { |
141 | 141 | return new ModelDescription( |
142 | - $this->driver->describeTable($table)[$table], $relationships, function ($type) { |
|
142 | + $this->driver->describeTable($table)[$table], $relationships, function($type) { |
|
143 | 143 | return $this->mapDataTypes($type); |
144 | 144 | } |
145 | 145 | ); |
@@ -74,7 +74,7 @@ |
||
74 | 74 | |
75 | 75 | public function preSave(&$wrapper, $value) |
76 | 76 | { |
77 | - if(!$value->save()) { |
|
77 | + if (!$value->save()) { |
|
78 | 78 | $this->invalidFields = $value->getInvalidFields(); |
79 | 79 | } |
80 | 80 | $wrapper[$this->options['local_key']] = $value[$this->options['foreign_key']]; |
@@ -110,7 +110,7 @@ |
||
110 | 110 | $jointModelRecords = []; |
111 | 111 | foreach ($this->tempdata as $relatedRecord) { |
112 | 112 | if (!$relatedRecord->save()) { |
113 | - $this->invalidFields =$this->tempdata->getInvalidFields(); |
|
113 | + $this->invalidFields = $this->tempdata->getInvalidFields(); |
|
114 | 114 | } |
115 | 115 | $jointModelRecords[] = [ |
116 | 116 | $this->options['junction_local_key'] => $wrapper[$this->options['local_key']], |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | { |
40 | 40 | // @todo throw an exception when the data doesn't have the local key |
41 | 41 | $query = $this->createQuery(); |
42 | - if(!$this->queryPrepared) { |
|
42 | + if (!$this->queryPrepared) { |
|
43 | 43 | $query->setTable($this->getModelInstance()->getDBStoreInformation()['quoted_table']) |
44 | 44 | ->addFilter($this->options['foreign_key'], $data[$this->options['local_key']] ?? null); |
45 | 45 | $this->queryPrepared = true; |
46 | 46 | return $query; |
47 | 47 | } |
48 | - if(isset($data[$this->options['local_key']])) { |
|
48 | + if (isset($data[$this->options['local_key']])) { |
|
49 | 49 | $query->setBoundData($this->options['foreign_key'], $data[$this->options['local_key']]); |
50 | 50 | } |
51 | 51 | return $query; |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | public function postSave(&$wrapper) |
71 | 71 | { |
72 | 72 | $records = $this->tempData->getData(); |
73 | - foreach($records as $i => $relatedRecord) { |
|
73 | + foreach ($records as $i => $relatedRecord) { |
|
74 | 74 | $records[$i][$this->options['foreign_key']] = $wrapper[$this->options['local_key']]; |
75 | 75 | } |
76 | 76 | $this->tempData->setData($records); |
77 | - if(!$this->tempData->save()) { |
|
77 | + if (!$this->tempData->save()) { |
|
78 | 78 | $this->invalidFields = $this->tempData->getInvalidFields(); |
79 | 79 | } |
80 | 80 | $wrapper[$this->options['model']] = $this->tempData; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $this->initialize(); |
190 | 190 | |
191 | 191 | return $this->context->getCache()->read( |
192 | - "{$this->className}::desc", function () { |
|
192 | + "{$this->className}::desc", function() { |
|
193 | 193 | return $this->context->getModelDescription($this); |
194 | 194 | } |
195 | 195 | ); |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | return null; |
419 | 419 | } |
420 | 420 | $name = $relationship->getOptions()['name']; |
421 | - if(isset($data[$name])) |
|
421 | + if (isset($data[$name])) |
|
422 | 422 | { |
423 | 423 | return $data[$name]; |
424 | 424 | } |
425 | 425 | $query = $relationship->prepareQuery($data); |
426 | 426 | |
427 | - if($query) { |
|
427 | + if ($query) { |
|
428 | 428 | $model = $relationship->getModelInstance(); |
429 | 429 | return $model->fetch($query); |
430 | 430 | } else { |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | $allExpandableModels = empty($expandableModels) ? array_keys($relationships) : $expandableModels; |
523 | 523 | foreach ($allExpandableModels as $name) { |
524 | 524 | $value = $this->fetchRelatedFields($relationships[$name], $index); |
525 | - if($value) { |
|
525 | + if ($value) { |
|
526 | 526 | $array[$name] = $value->toArray($depth, $expandableModels); |
527 | 527 | } else { |
528 | 528 | $array[$name] = null; |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | /** |
560 | 560 | * Return an instance of the model populated with array data. |
561 | 561 | */ |
562 | - public function fromArray(array $data, bool $isFromQuery=false): RecordWrapper |
|
562 | + public function fromArray(array $data, bool $isFromQuery = false): RecordWrapper |
|
563 | 563 | { |
564 | 564 | // Create a new instance if this model already has data. |
565 | - if($this->hasDataBeenSet) { |
|
565 | + if ($this->hasDataBeenSet) { |
|
566 | 566 | $instance = new $this->className(); |
567 | 567 | } else { |
568 | 568 | $instance = $this; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | foreach ($relationshipsWithData as $model => $relationship) { |
257 | 257 | $relationship->postSave($record); |
258 | 258 | $invalidRelatedFields = $relationship->getInvalidFields(); |
259 | - if(!empty($invalidRelatedFields)) { |
|
259 | + if (!empty($invalidRelatedFields)) { |
|
260 | 260 | $status['success'] = false; |
261 | 261 | $status['invalid_fields'][$model] = $invalidRelatedFields; |
262 | 262 | } |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | $mainValidatorErrors = $validator->getInvalidFields(); |
285 | 285 | } |
286 | 286 | |
287 | - if(!empty($this->wrapper->getValidationRules())) { |
|
287 | + if (!empty($this->wrapper->getValidationRules())) { |
|
288 | 288 | $modelValidator = new Validator(); |
289 | 289 | $modelValidator->setRules($this->wrapper->getValidationRules()); |
290 | - if(!$modelValidator->validate($data)) { |
|
290 | + if (!$modelValidator->validate($data)) { |
|
291 | 291 | $modelValidatorErrors = $modelValidator->getInvalidFields(); |
292 | 292 | } |
293 | 293 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return bool |
306 | 306 | */ |
307 | - private function isPrimaryKeySet(string|array $primaryKey, array $data) : bool |
|
307 | + private function isPrimaryKeySet(string | array $primaryKey, array $data) : bool |
|
308 | 308 | { |
309 | 309 | if (is_string($primaryKey) && ($data[$primaryKey] !== null || $data[$primaryKey] !== '')) { |
310 | 310 | return true; |
@@ -191,7 +191,7 @@ |
||
191 | 191 | * |
192 | 192 | * @return RecordWrapper |
193 | 193 | */ |
194 | - public function doFields(string|array ...$arguments) |
|
194 | + public function doFields(string | array ...$arguments) |
|
195 | 195 | { |
196 | 196 | $finalFields = []; |
197 | 197 | foreach ($arguments as $argument) { |