| @@ -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'; | 
| @@ -70,11 +70,11 @@ | ||
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | 72 |          if (!isset($this->options['junction_local_key'])) { | 
| 73 | - $this->options['junction_local_key'] = Text::singularize($this->setupTable) . '_id'; | |
| 73 | + $this->options['junction_local_key'] = Text::singularize($this->setupTable).'_id'; | |
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | 76 |          if (!isset($this->options['junction_foreign_key'])) { | 
| 77 | - $this->options['junction_foreign_key'] = Text::singularize($foreignModel->getDBStoreInformation()['table']) . '_id'; | |
| 77 | + $this->options['junction_foreign_key'] = Text::singularize($foreignModel->getDBStoreInformation()['table']).'_id'; | |
| 78 | 78 | } | 
| 79 | 79 | } | 
| 80 | 80 | |
| @@ -26,10 +26,10 @@ | ||
| 26 | 26 | |
| 27 | 27 | namespace ntentan\nibii\relationships; | 
| 28 | 28 | |
| 29 | -use ntentan\utils\Text; | |
| 30 | 29 | use ntentan\nibii\NibiiException; | 
| 31 | -use ntentan\nibii\Relationship; | |
| 32 | 30 | use ntentan\nibii\ORMContext; | 
| 31 | +use ntentan\nibii\Relationship; | |
| 32 | +use ntentan\utils\Text; | |
| 33 | 33 | |
| 34 | 34 | class ManyHaveManyRelationship extends Relationship | 
| 35 | 35 |  { | 
| @@ -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']) | 
| @@ -60,7 +60,7 @@ | ||
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 |      public function getQuery() { | 
| 63 | -        if(!$this->query) { | |
| 63 | +        if (!$this->query) { | |
| 64 | 64 | $this->query = new QueryParameters(); | 
| 65 | 65 | } | 
| 66 | 66 | return $this->query; | 
| @@ -67,11 +67,11 @@ discard block | ||
| 67 | 67 | } | 
| 68 | 68 | |
| 69 | 69 |      public function getWhereClause() { | 
| 70 | -        if($this->whereClause) { | |
| 71 | -            foreach($this->boundArrays as $boundArray) { | |
| 70 | +        if ($this->whereClause) { | |
| 71 | +            foreach ($this->boundArrays as $boundArray) { | |
| 72 | 72 | $where = ""; | 
| 73 | 73 | $comma = ""; | 
| 74 | -                for($i = 0; $i < count($this->boundData[$boundArray]); $i++) { | |
| 74 | +                for ($i = 0; $i < count($this->boundData[$boundArray]); $i++) { | |
| 75 | 75 |                      $where .= "{$comma}:{$boundArray}_{$i}"; | 
| 76 | 76 | $comma = ', '; | 
| 77 | 77 | } | 
| @@ -82,11 +82,11 @@ discard block | ||
| 82 | 82 | } | 
| 83 | 83 | |
| 84 | 84 |      public function getBoundData() { | 
| 85 | -        if($this->preparedBoundData === false) { | |
| 85 | +        if ($this->preparedBoundData === false) { | |
| 86 | 86 | $this->preparedBoundData = []; | 
| 87 | -            foreach($this->boundData as $key => $value) { | |
| 88 | -                if(in_array($key, $this->boundArrays)) { | |
| 89 | -                    foreach($value as $i => $v) { | |
| 87 | +            foreach ($this->boundData as $key => $value) { | |
| 88 | +                if (in_array($key, $this->boundArrays)) { | |
| 89 | +                    foreach ($value as $i => $v) { | |
| 90 | 90 |                          $this->preparedBoundData["{$key}_{$i}"] = $v; | 
| 91 | 91 | } | 
| 92 | 92 |                  } else { | 
| @@ -98,10 +98,10 @@ discard block | ||
| 98 | 98 | } | 
| 99 | 99 | |
| 100 | 100 |      public function setBoundData($key, $value) { | 
| 101 | -        if(isset($this->boundData[$key])){ | |
| 101 | +        if (isset($this->boundData[$key])) { | |
| 102 | 102 | $isArray = is_array($value); | 
| 103 | 103 | $boundArray = in_array($key, $this->boundArrays); | 
| 104 | -            if($isArray && !$boundArray) { | |
| 104 | +            if ($isArray && !$boundArray) { | |
| 105 | 105 |                  throw new NibiiException("{$key} cannot be bound to an array"); | 
| 106 | 106 |              } else if (!$isArray && $boundArray) { | 
| 107 | 107 |                  throw new NibiiException("{$key} must be bound to an array"); | 
| @@ -114,7 +114,7 @@ discard block | ||
| 114 | 114 | } | 
| 115 | 115 | |
| 116 | 116 |      public function getSorts() { | 
| 117 | -        return count($this->sorts) ? " ORDER BY " . implode(", ", $this->sorts) : null; | |
| 117 | +        return count($this->sorts) ? " ORDER BY ".implode(", ", $this->sorts) : null; | |
| 118 | 118 | } | 
| 119 | 119 | |
| 120 | 120 |      public function addFilter($field, $values = null) { | 
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 | |
| 54 | 54 |      public function runSetup() { | 
| 55 | 55 |          if ($this->options['foreign_key'] == null) { | 
| 56 | - $this->options['foreign_key'] = Text::singularize($this->setupTable) . '_id'; | |
| 56 | + $this->options['foreign_key'] = Text::singularize($this->setupTable).'_id'; | |
| 57 | 57 | } | 
| 58 | 58 |          if ($this->options['local_key'] == null) { | 
| 59 | 59 | $this->options['local_key'] = $this->setupPrimaryKey[0]; | 
| @@ -27,7 +27,6 @@ | ||
| 27 | 27 | namespace ntentan\nibii\relationships; | 
| 28 | 28 | |
| 29 | 29 | use ntentan\utils\Text; | 
| 30 | -use ntentan\nibii\ORMContext; | |
| 31 | 30 | |
| 32 | 31 |  class HasManyRelationship extends \ntentan\nibii\Relationship { | 
| 33 | 32 | |
| @@ -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) { |