@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $filter = $junctionModel->fields($this->options['junction_foreign_key']) |
| 47 | 47 | ->filterBy($this->options['junction_local_key'], $data[$this->options['local_key']]) |
| 48 | 48 | ->fetch(); |
| 49 | - if($filter->count() == 0) { |
|
| 49 | + if ($filter->count() == 0) { |
|
| 50 | 50 | return null; |
| 51 | 51 | } |
| 52 | 52 | $foreignKeys = []; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | // @todo throw an exception when the data doesn't have the local key |
| 58 | 58 | $query = $this->getQuery(); |
| 59 | - if($this->queryPrepared){ |
|
| 59 | + if ($this->queryPrepared) { |
|
| 60 | 60 | $query->setBoundData($this->options['foreign_key'], $foreignKeys); |
| 61 | 61 | } else { |
| 62 | 62 | $query = $this->getQuery() |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | if (!isset($this->options['junction_local_key'])) { |
| 92 | 92 | $this->options['junction_local_key'] = |
| 93 | - Text::singularize($this->setupTable) . '_id'; |
|
| 93 | + Text::singularize($this->setupTable).'_id'; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | if (!isset($this->options['junction_foreign_key'])) { |
| 97 | 97 | $this->options['junction_foreign_key'] = |
| 98 | - Text::singularize($foreignModel->getDBStoreInformation()['table']) . '_id'; |
|
| 98 | + Text::singularize($foreignModel->getDBStoreInformation()['table']).'_id'; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | public function postSave(&$wrapper) { |
| 112 | 112 | $jointModelRecords = []; |
| 113 | - foreach($this->tempdata as $relatedRecord) { |
|
| 113 | + foreach ($this->tempdata as $relatedRecord) { |
|
| 114 | 114 | $data = $relatedRecord->toArray(); |
| 115 | - if(!isset($data[$this->options['foreign_key']]) || (isset($data[$this->options['foreign_key']]) && count($data) > 1)) { |
|
| 116 | - if(!$relatedRecord->save()) { |
|
| 115 | + if (!isset($data[$this->options['foreign_key']]) || (isset($data[$this->options['foreign_key']]) && count($data) > 1)) { |
|
| 116 | + if (!$relatedRecord->save()) { |
|
| 117 | 117 | throw new NibiiException("Failed to save related model {$this->options['model']}"); |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | $classes = [$classA['class'], $classB['class']]; |
| 42 | 42 | sort($classes); |
| 43 | - return "{$classA['namespace']}\\" . implode('', $classes); |
|
| 43 | + return "{$classA['namespace']}\\".implode('', $classes); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public function getTableName($instance) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public static function getDriverAdapterClassName($driver = false) { |
| 53 | 53 | if ($driver) { |
| 54 | - return __NAMESPACE__ . '\adapters\\' . Text::ucamelize($driver) . 'Adapter'; |
|
| 54 | + return __NAMESPACE__.'\adapters\\'.Text::ucamelize($driver).'Adapter'; |
|
| 55 | 55 | } |
| 56 | 56 | throw new NibiiException("Please specify a driver"); |
| 57 | 57 | } |
@@ -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 | |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | private $initialized = false; |
| 64 | 64 | |
| 65 | 65 | private function initialize() { |
| 66 | - if($this->initialized) return; |
|
| 66 | + if ($this->initialized) return; |
|
| 67 | 67 | $this->context = ORMContext::getInstance(); |
| 68 | 68 | $this->container = $this->context->getContainer(); |
| 69 | 69 | $this->adapter = $this->container->resolve(DriverAdapter::class); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $invalidFields = []; |
| 62 | 62 | $data = $this->wrapper->getData(); |
| 63 | 63 | |
| 64 | - if(empty($data)) { |
|
| 64 | + if (empty($data)) { |
|
| 65 | 65 | return true; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | $relationships = $this->wrapper->getDescription()->getRelationships(); |
| 160 | 160 | $presentRelationships = []; |
| 161 | 161 | |
| 162 | - foreach($relationships ?? [] as $model => $relationship) { |
|
| 163 | - if(isset($record[$model])) { |
|
| 162 | + foreach ($relationships ?? [] as $model => $relationship) { |
|
| 163 | + if (isset($record[$model])) { |
|
| 164 | 164 | $relationship->preSave($record, $record[$model]); |
| 165 | 165 | $presentRelationships[$model] = $relationship; |
| 166 | 166 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | // Reset the data so it contains any modifications made by callbacks |
| 184 | 184 | $record = $this->wrapper->getData()[0]; |
| 185 | - foreach($presentRelationships as $model => $relationship) { |
|
| 185 | + foreach ($presentRelationships as $model => $relationship) { |
|
| 186 | 186 | $relationship->postSave($record); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | 'comma' => ',' |
| 43 | 43 | ); |
| 44 | 44 | private $operators = array( |
| 45 | - array('between', 'or' , 'like'), |
|
| 45 | + array('between', 'or', 'like'), |
|
| 46 | 46 | array('and'), |
| 47 | 47 | array('not'), |
| 48 | 48 | array('equals', 'greater', 'less', 'greater_or_equal', 'less_or_equal', 'not_equal', 'is'), |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $this->getToken(); |
| 58 | 58 | $expression = $this->parseExpression(); |
| 59 | 59 | if ($this->token !== false) { |
| 60 | - throw new FilterCompilerException("Unexpected '" . $this->token . "' in filter [$filter]"); |
|
| 60 | + throw new FilterCompilerException("Unexpected '".$this->token."' in filter [$filter]"); |
|
| 61 | 61 | } |
| 62 | 62 | $parsed = $this->renderExpression($expression); |
| 63 | 63 | return $parsed; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | private function renderExpression($expression) { |
| 67 | 67 | if (is_array($expression)) { |
| 68 | - $expression = $this->renderExpression($expression['left']) . " {$expression['opr']} " . $this->renderExpression($expression['right']); |
|
| 68 | + $expression = $this->renderExpression($expression['left'])." {$expression['opr']} ".$this->renderExpression($expression['right']); |
|
| 69 | 69 | } |
| 70 | 70 | return $expression; |
| 71 | 71 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $tokens = [$tokens]; |
| 76 | 76 | } |
| 77 | 77 | if (array_search($this->lookahead, $tokens) === false) { |
| 78 | - throw new FilterCompilerException("Expected " . implode(' or ', $tokens) . " but found " . $this->lookahead); |
|
| 78 | + throw new FilterCompilerException("Expected ".implode(' or ', $tokens)." but found ".$this->lookahead); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | private function returnPositionTag() { |
| 163 | - return ":filter_bind_" . ( ++$this->numPositions); |
|
| 163 | + return ":filter_bind_".( ++$this->numPositions); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | private function parseObracket() { |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if ($this->token === false && strlen($this->filter) > 0) { |
| 240 | - throw new FilterCompilerException("Unexpected character [" . $this->filter[0] . "] begining " . $this->filter . "."); |
|
| 240 | + throw new FilterCompilerException("Unexpected character [".$this->filter[0]."] begining ".$this->filter."."); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $rewritten = []; |
| 252 | 252 | foreach ($data as $key => $value) { |
| 253 | 253 | if (is_numeric($key)) { |
| 254 | - $rewritten["filter_bind_" . ($key + 1)] = $value; |
|
| 254 | + $rewritten["filter_bind_".($key + 1)] = $value; |
|
| 255 | 255 | } else { |
| 256 | 256 | $rewritten[$key] = $value; |
| 257 | 257 | } |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | $valueFields[] = ":{$field}"; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return "INSERT INTO " . $table . |
|
| 33 | - " (" . implode(", ", $quotedFields) . ") VALUES (" . implode(', ', $valueFields) . ")"; |
|
| 32 | + return "INSERT INTO ".$table. |
|
| 33 | + " (".implode(", ", $quotedFields).") VALUES (".implode(', ', $valueFields).")"; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function getBulkUpdateQuery($data, $parameters) { |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return "UPDATE " . |
|
| 75 | - $model->getDBStoreInformation()['quoted_table'] . |
|
| 76 | - " SET " . implode(', ', $valueFields) . |
|
| 77 | - " WHERE " . implode(' AND ', $conditions); |
|
| 74 | + return "UPDATE ". |
|
| 75 | + $model->getDBStoreInformation()['quoted_table']. |
|
| 76 | + " SET ".implode(', ', $valueFields). |
|
| 77 | + " WHERE ".implode(' AND ', $conditions); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function getSelectQuery($parameters) { |