@@ -17,5 +17,10 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | interface ValidatorFactoryInterface |
| 19 | 19 | { |
| 20 | + /** |
|
| 21 | + * @param integer $mode |
|
| 22 | + * |
|
| 23 | + * @return \ntentan\nibii\DefaultValidator |
|
| 24 | + */ |
|
| 20 | 25 | public function createModelValidator(RecordWrapper $model, $mode); |
| 21 | 26 | } |
@@ -12,7 +12,17 @@ |
||
| 12 | 12 | interface ModelFactoryInterface |
| 13 | 13 | { |
| 14 | 14 | public function createModel($name, $context); |
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @param \ntentan\nibii\RecordWrapper $instance |
|
| 18 | + * |
|
| 19 | + * @return string |
|
| 20 | + */ |
|
| 15 | 21 | public function getModelTable($instance); |
| 16 | 22 | public function getClassName($model); |
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 17 | 27 | public function getJunctionClassName($classA, $classB); |
| 18 | 28 | } |
| 19 | 29 | \ No newline at end of file |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | $valueFields[] = ":{$field}"; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return "INSERT INTO " . $table . |
|
| 36 | - " (" . implode(", ", $quotedFields) . ") VALUES (" . implode(', ', $valueFields) . ")"; |
|
| 35 | + return "INSERT INTO ".$table. |
|
| 36 | + " (".implode(", ", $quotedFields).") VALUES (".implode(', ', $valueFields).")"; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function getBulkUpdateQuery($data, $parameters) |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - return "UPDATE " . |
|
| 80 | - $model->getDBStoreInformation()['quoted_table'] . |
|
| 81 | - " SET " . implode(', ', $valueFields) . |
|
| 82 | - " WHERE " . implode(' AND ', $conditions); |
|
| 79 | + return "UPDATE ". |
|
| 80 | + $model->getDBStoreInformation()['quoted_table']. |
|
| 81 | + " SET ".implode(', ', $valueFields). |
|
| 82 | + " WHERE ".implode(' AND ', $conditions); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | public function getSelectQuery($parameters) |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | |
| 128 | 128 | public function getSorts() |
| 129 | 129 | { |
| 130 | - return count($this->sorts) ? " ORDER BY " . implode(", ", $this->sorts) : null; |
|
| 130 | + return count($this->sorts) ? " ORDER BY ".implode(", ", $this->sorts) : null; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function addFilter($field, $values = null) |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | public function describe($model, $relationships) |
| 114 | 114 | { |
| 115 | 115 | return new ModelDescription( |
| 116 | - $this->driver->describeTable($table)[$table], $relationships, function ($type) { |
|
| 116 | + $this->driver->describeTable($table)[$table], $relationships, function($type) { |
|
| 117 | 117 | return $this->mapDataTypes($type); |
| 118 | 118 | } |
| 119 | 119 | ); |
@@ -28,7 +28,6 @@ |
||
| 28 | 28 | |
| 29 | 29 | use ntentan\atiaa\Driver; |
| 30 | 30 | use ntentan\nibii\exceptions\ModelNotFoundException; |
| 31 | -use ntentan\nibii\exceptions\NibiiException; |
|
| 32 | 31 | use ntentan\utils\Text; |
| 33 | 32 | |
| 34 | 33 | /** |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | public function doFilter() |
| 241 | 241 | { |
| 242 | 242 | $arguments = func_get_args(); |
| 243 | - if(count($arguments) == 1 && is_array($arguments[0])) { |
|
| 244 | - foreach($arguments[0] as $field => $value) { |
|
| 243 | + if (count($arguments) == 1 && is_array($arguments[0])) { |
|
| 244 | + foreach ($arguments[0] as $field => $value) { |
|
| 245 | 245 | $this->getQueryParameters()->addFilter($field, $value); |
| 246 | 246 | } |
| 247 | 247 | } else { |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | public function doWith($model) |
| 351 | 351 | { |
| 352 | - if(!isset($this->wrapper->getDescription()->getRelationships()[$model])) { |
|
| 352 | + if (!isset($this->wrapper->getDescription()->getRelationships()[$model])) { |
|
| 353 | 353 | throw new ModelNotFoundException("Could not find related model [$model]"); |
| 354 | 354 | } |
| 355 | 355 | $relationship = $this->wrapper->getDescription()->getRelationships()[$model]; |
@@ -26,10 +26,10 @@ |
||
| 26 | 26 | |
| 27 | 27 | namespace ntentan\nibii\relationships; |
| 28 | 28 | |
| 29 | -use ntentan\nibii\exceptions\FieldNotFoundException; |
|
| 29 | +use ntentan\nibii\ORMContext; |
|
| 30 | 30 | use ntentan\nibii\Relationship; |
| 31 | +use ntentan\nibii\exceptions\FieldNotFoundException; |
|
| 31 | 32 | use ntentan\utils\Text; |
| 32 | -use ntentan\nibii\ORMContext; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Represents a one to many belongs to relationship. |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function prepareQuery($data) |
| 45 | 45 | { |
| 46 | - if(!array_key_exists($this->options['local_key'], $data)) { |
|
| 46 | + if (!array_key_exists($this->options['local_key'], $data)) { |
|
| 47 | 47 | throw new FieldNotFoundException("Field {$this->options['local_key']} not found for belongs to relationship query."); |
| 48 | 48 | } |
| 49 | - if(!isset($data[$this->options['local_key']])) { |
|
| 49 | + if (!isset($data[$this->options['local_key']])) { |
|
| 50 | 50 | return null; |
| 51 | 51 | } |
| 52 | 52 | $query = $this->getQuery(); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $this->options['foreign_key'] = $model->getDescription()->getPrimaryKey()[0]; |
| 70 | 70 | } |
| 71 | 71 | if ($this->options['local_key'] == null) { |
| 72 | - $this->options['local_key'] = Text::singularize($table) . '_id'; |
|
| 72 | + $this->options['local_key'] = Text::singularize($table).'_id'; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | $this->table = $table['table']; |
| 136 | 136 | $this->schema = $table['schema']; |
| 137 | 137 | } |
| 138 | - $this->quotedTable = ($this->schema ? "{$driver->quoteIdentifier($this->schema)}." : "") . $driver->quoteIdentifier($this->table); |
|
| 139 | - $this->unquotedTable = ($this->schema ? "{$this->schema}." : "") . $this->table; |
|
| 138 | + $this->quotedTable = ($this->schema ? "{$driver->quoteIdentifier($this->schema)}." : "").$driver->quoteIdentifier($this->table); |
|
| 139 | + $this->unquotedTable = ($this->schema ? "{$this->schema}." : "").$this->table; |
|
| 140 | 140 | $this->adapter->setModel($this, $this->quotedTable); |
| 141 | 141 | $this->initialized = true; |
| 142 | 142 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $this->initialize(); |
| 157 | 157 | return $this->context->getCache()->read( |
| 158 | - "{$this->className}::desc", function () { |
|
| 158 | + "{$this->className}::desc", function() { |
|
| 159 | 159 | return $this->context->getModelDescription($this); |
| 160 | 160 | } |
| 161 | 161 | ); |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | * Callback for when a new record has been created. |
| 466 | 466 | * This callback can be most useful for obtaining the primary key of a newly created record. |
| 467 | 467 | * |
| 468 | - * @param $id |
|
| 468 | + * @param string $id |
|
| 469 | 469 | */ |
| 470 | 470 | public function postCreateCallback($id) |
| 471 | 471 | { |
@@ -509,6 +509,10 @@ discard block |
||
| 509 | 509 | return $this->adapter; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | + /** |
|
| 513 | + * @param Relationship[] $relationships |
|
| 514 | + * @param integer $depth |
|
| 515 | + */ |
|
| 512 | 516 | private function expandArrayValue($array, $relationships, $depth, $expandableModels = [], $index = null) |
| 513 | 517 | { |
| 514 | 518 | if (empty($expandableModels)) { |
@@ -25,6 +25,9 @@ discard block |
||
| 25 | 25 | 'save', 'validate' |
| 26 | 26 | ]; |
| 27 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string $table |
|
| 30 | + */ |
|
| 28 | 31 | public function __construct(RecordWrapper $wrapper, $table) |
| 29 | 32 | { |
| 30 | 33 | $this->wrapper = $wrapper; |
@@ -34,6 +37,9 @@ discard block |
||
| 34 | 37 | $this->queryOperations = new QueryOperations($wrapper, $this->dataOperations, $driver); |
| 35 | 38 | } |
| 36 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $name |
|
| 42 | + */ |
|
| 37 | 43 | public function perform($name, $arguments) |
| 38 | 44 | { |
| 39 | 45 | //@todo Think of using a hash here in future |