@@ -90,6 +90,9 @@ |
||
| 90 | 90 | return $relationshipDetails; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | + /** |
|
| 94 | + * @param string $type |
|
| 95 | + */ |
|
| 93 | 96 | private function createRelationships($type, $relationships) { |
| 94 | 97 | foreach ($relationships as $relationship) { |
| 95 | 98 | $relationship = $this->getRelationshipDetails($relationship); |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | return null; |
| 88 | 88 | } |
| 89 | 89 | $relationshipDetails['local_table'] = $this->table; |
| 90 | - if(isset($relationship['through'])) { |
|
| 90 | + if (isset($relationship['through'])) { |
|
| 91 | 91 | $relationshipDetails['through'] = $relationship['through']; |
| 92 | 92 | } |
| 93 | 93 | return $relationshipDetails; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * @method |
| 125 | - * @param type $name |
|
| 125 | + * @param string $name |
|
| 126 | 126 | * @param type $arguments |
| 127 | 127 | * @return type |
| 128 | 128 | */ |
@@ -148,6 +148,10 @@ discard block |
||
| 148 | 148 | return $this->retrieveItem($name); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | + /** |
|
| 152 | + * @param Relationship[] $relationships |
|
| 153 | + * @param integer $depth |
|
| 154 | + */ |
|
| 151 | 155 | private function expandArrayValue($array, $relationships, $depth, $index = null) { |
| 152 | 156 | foreach ($relationships as $name => $relationship) { |
| 153 | 157 | $array[$name] = $this->fetchRelatedFields($relationship, $index)->toArray($depth); |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $this->filter( |
| 37 | - "INSERT INTO " . $table . |
|
| 38 | - " (" . implode(", ", $quotedFields) . ") VALUES (" . implode(', ', $valueFields) . ")" |
|
| 37 | + "INSERT INTO ".$table. |
|
| 38 | + " (".implode(", ", $quotedFields).") VALUES (".implode(', ', $valueFields).")" |
|
| 39 | 39 | ); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - return $this->filter("UPDATE " . |
|
| 81 | - $model->getDBStoreInformation()['quoted_table'] . |
|
| 82 | - " SET " . implode(', ', $valueFields) . |
|
| 83 | - " WHERE " . implode(' AND ', $conditions) |
|
| 80 | + return $this->filter("UPDATE ". |
|
| 81 | + $model->getDBStoreInformation()['quoted_table']. |
|
| 82 | + " SET ".implode(', ', $valueFields). |
|
| 83 | + " WHERE ".implode(' AND ', $conditions) |
|
| 84 | 84 | ); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -10,6 +10,9 @@ discard block |
||
| 10 | 10 | $this->db = $driver; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | + /** |
|
| 14 | + * @param string $query |
|
| 15 | + */ |
|
| 13 | 16 | private function filter($query) { |
| 14 | 17 | return $query; |
| 15 | 18 | } |
@@ -39,6 +42,9 @@ discard block |
||
| 39 | 42 | ); |
| 40 | 43 | } |
| 41 | 44 | |
| 45 | + /** |
|
| 46 | + * @param QueryParameters $parameters |
|
| 47 | + */ |
|
| 42 | 48 | public function getBulkUpdateQuery($data, $parameters) { |
| 43 | 49 | $updateData = []; |
| 44 | 50 | foreach ($data as $field => $value) { |
@@ -84,6 +90,9 @@ discard block |
||
| 84 | 90 | ); |
| 85 | 91 | } |
| 86 | 92 | |
| 93 | + /** |
|
| 94 | + * @param QueryParameters $parameters |
|
| 95 | + */ |
|
| 87 | 96 | public function getSelectQuery($parameters) { |
| 88 | 97 | return $this->filter(sprintf( |
| 89 | 98 | "SELECT %s FROM %s%s%s%s%s", |
@@ -97,6 +106,9 @@ discard block |
||
| 97 | 106 | ); |
| 98 | 107 | } |
| 99 | 108 | |
| 109 | + /** |
|
| 110 | + * @param QueryParameters $parameters |
|
| 111 | + */ |
|
| 100 | 112 | public function getCountQuery($parameters) { |
| 101 | 113 | return $this->filter(sprintf( |
| 102 | 114 | "SELECT count(*) as count FROM %s%s", |
@@ -106,6 +118,9 @@ discard block |
||
| 106 | 118 | ); |
| 107 | 119 | } |
| 108 | 120 | |
| 121 | + /** |
|
| 122 | + * @param QueryParameters $parameters |
|
| 123 | + */ |
|
| 109 | 124 | public function getDeleteQuery($parameters) { |
| 110 | 125 | return $this->filter(sprintf( |
| 111 | 126 | "DELETE FROM %s%s", |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function getSorts() { |
| 73 | - return count($this->sorts) ? " ORDER BY " . implode(", ", $this->sorts) : null; |
|
| 73 | + return count($this->sorts) ? " ORDER BY ".implode(", ", $this->sorts) : null; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function addFilter($field, $values = []) { |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->whereClause .= "{$field} IN ("; |
| 91 | 91 | $comma = ''; |
| 92 | 92 | for ($i = 0; $i < $numValues; $i++) { |
| 93 | - $key = "filter_" . ($startIndex + $i); |
|
| 93 | + $key = "filter_".($startIndex + $i); |
|
| 94 | 94 | $this->whereClause .= "$comma:$key"; |
| 95 | 95 | $this->boundData[$key] = $values[$i]; |
| 96 | 96 | $comma = ' ,'; |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public static function getInstance() { |
| 70 | - if(self::$instance === null) throw new NibiiException("A context has not yet been initialized"); |
|
| 70 | + if (self::$instance === null) throw new NibiiException("A context has not yet been initialized"); |
|
| 71 | 71 | return self::$instance; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -67,7 +67,9 @@ |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public static function getInstance() { |
| 70 | - if(self::$instance === null) throw new NibiiException("A context has not yet been initialized"); |
|
| 70 | + if(self::$instance === null) { |
|
| 71 | + throw new NibiiException("A context has not yet been initialized"); |
|
| 72 | + } |
|
| 71 | 73 | return self::$instance; |
| 72 | 74 | } |
| 73 | 75 | |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return $this->evaluateResult( |
| 71 | - $field, $testItem->count() === 0, "The value of " . implode(', ', $field['name']) . " must be unique" |
|
| 71 | + $field, $testItem->count() === 0, "The value of ".implode(', ', $field['name'])." must be unique" |
|
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $filter = $junctionModel->fields($this->options['junction_foreign_key']) |
| 45 | 45 | ->filterBy($this->options['junction_local_key'], $data[$this->options['local_key']]) |
| 46 | 46 | ->fetch(); |
| 47 | - if($filter->count() == 0) { |
|
| 47 | + if ($filter->count() == 0) { |
|
| 48 | 48 | return null; |
| 49 | 49 | } |
| 50 | 50 | $foreignKeys = []; |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | if (!isset($this->options['junction_local_key'])) { |
| 80 | 80 | $this->options['junction_local_key'] = |
| 81 | - Text::singularize($this->setupTable) . '_id'; |
|
| 81 | + Text::singularize($this->setupTable).'_id'; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if (!isset($this->options['junction_foreign_key'])) { |
| 85 | 85 | $this->options['junction_foreign_key'] = |
| 86 | - Text::singularize($foreignModel->getDBStoreInformation()['table']) . '_id'; |
|
| 86 | + Text::singularize($foreignModel->getDBStoreInformation()['table']).'_id'; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |