@@ -204,6 +204,10 @@ |
||
| 204 | 204 | return $return; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | + /** |
|
| 208 | + * @param integer $level |
|
| 209 | + * @param string $opr |
|
| 210 | + */ |
|
| 207 | 211 | private function parseRightExpression($level, $opr) |
| 208 | 212 | { |
| 209 | 213 | switch ($opr) { |
@@ -103,6 +103,9 @@ |
||
| 103 | 103 | return $relationshipDetails; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | + /** |
|
| 107 | + * @param string $type |
|
| 108 | + */ |
|
| 106 | 109 | private function createRelationships($type, $relationships) |
| 107 | 110 | { |
| 108 | 111 | foreach ($relationships as $relationship) { |
@@ -17,5 +17,8 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | interface ValidatorFactoryInterface |
| 19 | 19 | { |
| 20 | + /** |
|
| 21 | + * @return \ntentan\nibii\DefaultValidator |
|
| 22 | + */ |
|
| 20 | 23 | public function createModelValidator(RecordWrapper $model, $mode); |
| 21 | 24 | } |
@@ -89,6 +89,9 @@ |
||
| 89 | 89 | return $this->config; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | + /** |
|
| 93 | + * @param RecordWrapper $model |
|
| 94 | + */ |
|
| 92 | 95 | public function getModelDescription($model) : ModelDescription |
| 93 | 96 | { |
| 94 | 97 | return new ModelDescription($model); |
@@ -28,11 +28,22 @@ |
||
| 28 | 28 | |
| 29 | 29 | interface ModelFactoryInterface |
| 30 | 30 | { |
| 31 | + /** |
|
| 32 | + * @param string $name |
|
| 33 | + */ |
|
| 31 | 34 | public function createModel($name, $context); |
| 32 | 35 | |
| 36 | + /** |
|
| 37 | + * @param \ntentan\nibii\RecordWrapper $instance |
|
| 38 | + * |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 33 | 41 | public function getModelTable($instance); |
| 34 | 42 | |
| 35 | 43 | public function getClassName($model); |
| 36 | 44 | |
| 45 | + /** |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 37 | 48 | public function getJunctionClassName($classA, $classB); |
| 38 | 49 | } |
@@ -47,6 +47,9 @@ discard block |
||
| 47 | 47 | 'save', 'validate', |
| 48 | 48 | ]; |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string $table |
|
| 52 | + */ |
|
| 50 | 53 | public function __construct(RecordWrapper $wrapper, $table) |
| 51 | 54 | { |
| 52 | 55 | $this->wrapper = $wrapper; |
@@ -56,6 +59,9 @@ discard block |
||
| 56 | 59 | $this->queryOperations = new QueryOperations($wrapper, $this->dataOperations, $driver); |
| 57 | 60 | } |
| 58 | 61 | |
| 62 | + /** |
|
| 63 | + * @param string $name |
|
| 64 | + */ |
|
| 59 | 65 | public function perform($name, $arguments) |
| 60 | 66 | { |
| 61 | 67 | //@todo Think of using a hash here in future |
@@ -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 | ); |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * Callback for when a new record has been created. |
| 498 | 498 | * This callback can be most useful for obtaining the primary key of a newly created record. |
| 499 | 499 | * |
| 500 | - * @param $id |
|
| 500 | + * @param string $id |
|
| 501 | 501 | */ |
| 502 | 502 | public function postCreateCallback($id) |
| 503 | 503 | { |
@@ -538,6 +538,10 @@ discard block |
||
| 538 | 538 | return $this->adapter; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | + /** |
|
| 542 | + * @param Relationship[] $relationships |
|
| 543 | + * @param integer $depth |
|
| 544 | + */ |
|
| 541 | 545 | private function expandArrayValue($array, $relationships, $depth, $expandableModels = [], $index = null) |
| 542 | 546 | { |
| 543 | 547 | $expandableModels = empty($expandableModels) ? array_keys($relationships) : $expandableModels; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $this->initialize(); |
| 212 | 212 | |
| 213 | 213 | return $this->context->getCache()->read( |
| 214 | - "{$this->className}::desc", function () { |
|
| 214 | + "{$this->className}::desc", function() { |
|
| 215 | 215 | return $this->context->getModelDescription($this); |
| 216 | 216 | } |
| 217 | 217 | ); |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | { |
| 444 | 444 | $data = $index ? $this->modelData[$index] : $this->modelData; |
| 445 | 445 | $name = $relationship->getOptions()['name']; |
| 446 | - if(isset($data[$name])) |
|
| 446 | + if (isset($data[$name])) |
|
| 447 | 447 | { |
| 448 | 448 | return $data[$name]; |
| 449 | 449 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | foreach ($relationshipsWithData as $model => $relationship) { |
| 240 | 240 | $relationship->postSave($record); |
| 241 | 241 | $invalidRelatedFields = $relationship->getInvalidFields(); |
| 242 | - if(!empty($invalidRelatedFields)) { |
|
| 242 | + if (!empty($invalidRelatedFields)) { |
|
| 243 | 243 | $status['success'] = false; |
| 244 | 244 | $status['invalid_fields'][$model] = $invalidRelatedFields; |
| 245 | 245 | } |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | $mainValidatorErrors = $validator->getInvalidFields(); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if(!empty($this->wrapper->getValidationRules())) { |
|
| 268 | + if (!empty($this->wrapper->getValidationRules())) { |
|
| 269 | 269 | $modelValidator = new Validator(); |
| 270 | 270 | $modelValidator->setRules($this->wrapper->getValidationRules()); |
| 271 | - if(!$modelValidator->validate($data)) { |
|
| 271 | + if (!$modelValidator->validate($data)) { |
|
| 272 | 272 | $modelValidatorErrors = $modelValidator->getInvalidFields(); |
| 273 | 273 | } |
| 274 | 274 | } |