@@ -5,7 +5,7 @@ |
||
| 5 | 5 | { |
| 6 | 6 | public function mapDataTypes($nativeType) |
| 7 | 7 | { |
| 8 | - switch($nativeType) |
|
| 8 | + switch ($nativeType) |
|
| 9 | 9 | { |
| 10 | 10 | case 'int': |
| 11 | 11 | return 'integer'; |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function mapDataTypes($nativeType) |
| 14 | 14 | { |
| 15 | - switch($nativeType) |
|
| 15 | + switch ($nativeType) |
|
| 16 | 16 | { |
| 17 | 17 | case 'character varying': |
| 18 | 18 | return 'string'; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function preSaveCallback($data) |
| 18 | 18 | { |
| 19 | - if(isset($this->model->getDescription()->getFields()['created'])) |
|
| 19 | + if (isset($this->model->getDescription()->getFields()['created'])) |
|
| 20 | 20 | { |
| 21 | 21 | $data['created'] = date('Y-m-d H:i:s'); |
| 22 | 22 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function preUpdateCallback($data) |
| 27 | 27 | { |
| 28 | - if(isset($this->model->getDescription()->getFields()['updated'])) |
|
| 28 | + if (isset($this->model->getDescription()->getFields()['updated'])) |
|
| 29 | 29 | { |
| 30 | 30 | $data['updated'] = date('Y-m-d H:i:s'); |
| 31 | 31 | } |
@@ -9,5 +9,8 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | interface TableNameResolverInterface |
| 11 | 11 | { |
| 12 | + /** |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 12 | 15 | public function getTableName($instance); |
| 13 | 16 | } |
@@ -9,5 +9,8 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | interface ModelJoinerInterface |
| 11 | 11 | { |
| 12 | + /** |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 12 | 15 | public function getJunctionClassName($classA, $classB); |
| 13 | 16 | } |
@@ -190,6 +190,10 @@ |
||
| 190 | 190 | return $return; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | + /** |
|
| 194 | + * @param integer $level |
|
| 195 | + * @param string $opr |
|
| 196 | + */ |
|
| 193 | 197 | private function parseRightExpression($level, $opr) { |
| 194 | 198 | switch ($opr) { |
| 195 | 199 | case 'between': return $this->parseBetween(); |
@@ -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 | } |
@@ -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; |
@@ -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 | |
@@ -26,8 +26,8 @@ |
||
| 26 | 26 | |
| 27 | 27 | namespace ntentan\nibii\relationships; |
| 28 | 28 | |
| 29 | -use ntentan\utils\Text; |
|
| 30 | 29 | use ntentan\nibii\ORMContext; |
| 30 | +use ntentan\utils\Text; |
|
| 31 | 31 | |
| 32 | 32 | class BelongsToRelationship extends \ntentan\nibii\Relationship { |
| 33 | 33 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | public function prepareQuery($data) { |
| 42 | 42 | // @todo throw an exception when the data doesn't have the local key |
| 43 | 43 | $query = $this->getQuery(); |
| 44 | - if($this->queryPrepared){ |
|
| 44 | + if ($this->queryPrepared) { |
|
| 45 | 45 | $query->setBoundData($this->options['foreign_key'], $data[$this->options['local_key']]); |
| 46 | 46 | } else { |
| 47 | 47 | $query->setTable($this->getModelInstance()->getDBStoreInformation()['quoted_table']) |