| @@ -40,7 +40,7 @@ | ||
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** | 
| 43 | - * @param DibiFluent $data_source | |
| 43 | + * @param Dibi\Fluent $data_source | |
| 44 | 44 | * @param string $primary_key | 
| 45 | 45 | */ | 
| 46 | 46 | public function __construct(\Dibi\Fluent $data_source, $primary_key) | 
| @@ -171,7 +171,7 @@ discard block | ||
| 171 | 171 | \dibi::IDENTIFIER | 
| 172 | 172 | ); | 
| 173 | 173 | |
| 174 | -			if ($filter->isExactSearch()){ | |
| 174 | +			if ($filter->isExactSearch()) { | |
| 175 | 175 |  				$this->data_source->where("$column = %s", $value); | 
| 176 | 176 | continue; | 
| 177 | 177 | } | 
| @@ -303,7 +303,7 @@ discard block | ||
| 303 | 303 | |
| 304 | 304 | public function addAggregationColumn($aggregation_type, $column) | 
| 305 | 305 |  	{ | 
| 306 | - $this->aggregation_data_source = $this->aggregation_data_source->select($aggregation_type .'(%n)', $column)->as($column); | |
| 306 | + $this->aggregation_data_source = $this->aggregation_data_source->select($aggregation_type.'(%n)', $column)->as($column); | |
| 307 | 307 | } | 
| 308 | 308 | |
| 309 | 309 | public function getAggregationData() | 
| @@ -177,7 +177,7 @@ discard block | ||
| 177 | 177 | $exprs = []; | 
| 178 | 178 | |
| 179 | 179 |  		foreach ($filter->getCondition() as $column => $value) { | 
| 180 | -			if($filter->isExactSearch()) { | |
| 180 | +			if ($filter->isExactSearch()) { | |
| 181 | 181 | $exprs[] = Criteria::expr()->eq($column, $value); | 
| 182 | 182 | continue; | 
| 183 | 183 | } | 
| @@ -310,7 +310,7 @@ discard block | ||
| 310 | 310 | |
| 311 | 311 |  		foreach ($this->aggregations as $column => $aggregation_type) { | 
| 312 | 312 |  			if ($aggregation_type == ColumnAggregationFunction::$aggregation_type_avg) { | 
| 313 | - $result[$column] = $result[$column] / $this->data_source->count(); | |
| 313 | + $result[$column] = $result[$column] / $this->data_source->count(); | |
| 314 | 314 | } | 
| 315 | 315 | } | 
| 316 | 316 | return $result; | 
| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 | /** | 
| 24 | 24 | * @var array | 
| 25 | 25 | */ | 
| 26 | - protected $aggregations =[]; | |
| 26 | + protected $aggregations = []; | |
| 27 | 27 | |
| 28 | 28 | /** | 
| 29 | 29 | * @var array | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | return $this->data_source->count( | 
| 69 | - $this->data_source->getName() . '.' . (is_array($primary) ? reset($primary) : $primary) | |
| 69 | + $this->data_source->getName().'.'.(is_array($primary) ? reset($primary) : $primary) | |
| 70 | 70 | ); | 
| 71 | 71 | } | 
| 72 | 72 | |
| @@ -177,8 +177,8 @@ discard block | ||
| 177 | 177 |  			$like = '('; | 
| 178 | 178 | $args = []; | 
| 179 | 179 | |
| 180 | -			if($filter->isExactSearch()){ | |
| 181 | - $like .= "$column = ? OR "; | |
| 180 | +			if ($filter->isExactSearch()) { | |
| 181 | + $like .= "$column = ? OR "; | |
| 182 | 182 | $args[] = "$value"; | 
| 183 | 183 |  			} else { | 
| 184 | 184 |  				if ($filter->hasSplitWordsSearch() === FALSE) { | 
| @@ -191,7 +191,7 @@ discard block | ||
| 191 | 191 | $args[] = "%$word%"; | 
| 192 | 192 | } | 
| 193 | 193 | } | 
| 194 | - $like = substr($like, 0, strlen($like) - 4) . ')'; | |
| 194 | + $like = substr($like, 0, strlen($like) - 4).')'; | |
| 195 | 195 | |
| 196 | 196 | $or[] = $like; | 
| 197 | 197 | $big_or .= "$like OR "; | 
| @@ -229,9 +229,9 @@ discard block | ||
| 229 | 229 | |
| 230 | 230 |  			foreach ($values as $value) { | 
| 231 | 231 |  				if ($i == $length) { | 
| 232 | - $or .= $filter->getColumn() . ' = ?)'; | |
| 232 | + $or .= $filter->getColumn().' = ?)'; | |
| 233 | 233 |  				} else { | 
| 234 | - $or .= $filter->getColumn() . ' = ? OR '; | |
| 234 | + $or .= $filter->getColumn().' = ? OR '; | |
| 235 | 235 | } | 
| 236 | 236 | |
| 237 | 237 | $i++; | 
| @@ -241,7 +241,7 @@ discard block | ||
| 241 | 241 | |
| 242 | 242 | call_user_func_array([$this->data_source, 'where'], $values); | 
| 243 | 243 |  		} else { | 
| 244 | - $this->data_source->where($filter->getColumn() . ' = ?', reset($values)); | |
| 244 | + $this->data_source->where($filter->getColumn().' = ?', reset($values)); | |
| 245 | 245 | } | 
| 246 | 246 | } | 
| 247 | 247 | |
| @@ -327,7 +327,7 @@ discard block | ||
| 327 | 327 | $result = []; | 
| 328 | 328 | //there should really be some better way to do this and get all results in one query, this could be big performance issue on bigger tables | 
| 329 | 329 |  		foreach ($this->aggregations as $column => $aggregation_type) { | 
| 330 | -			$result[$column] = $this->data_source->aggregation($aggregation_type . '(' . $column . ')'); | |
| 330 | +			$result[$column] = $this->data_source->aggregation($aggregation_type.'('.$column.')'); | |
| 331 | 331 | } | 
| 332 | 332 | |
| 333 | 333 | return $result; | 
| @@ -107,8 +107,8 @@ discard block | ||
| 107 | 107 | $date_end = clone $date; | 
| 108 | 108 | |
| 109 | 109 | $this->data_source = $this->data_source->findBy([ | 
| 110 | - $this->prepareColumn($column) . '>=' => $date->setTime(0, 0, 0), | |
| 111 | - $this->prepareColumn($column) . '<=' => $date_end->setTime(23, 59, 59) | |
| 110 | + $this->prepareColumn($column).'>=' => $date->setTime(0, 0, 0), | |
| 111 | + $this->prepareColumn($column).'<=' => $date_end->setTime(23, 59, 59) | |
| 112 | 112 | ]); | 
| 113 | 113 | } | 
| 114 | 114 | |
| @@ -131,12 +131,12 @@ discard block | ||
| 131 | 131 | $dataCondition = []; | 
| 132 | 132 |  		if ($value_from) { | 
| 133 | 133 | $date_from = \DateTime::createFromFormat($filter->getPhpFormat(), $value_from); | 
| 134 | - $dataCondition[$this->prepareColumn($filter->getColumn()) . '>='] = $date_from->setTime(0, 0, 0); | |
| 134 | + $dataCondition[$this->prepareColumn($filter->getColumn()).'>='] = $date_from->setTime(0, 0, 0); | |
| 135 | 135 | } | 
| 136 | 136 | |
| 137 | 137 |  		if ($value_to) { | 
| 138 | 138 | $date_to = \DateTime::createFromFormat($filter->getPhpFormat(), $value_to); | 
| 139 | - $dataCondition[$this->prepareColumn($filter->getColumn()) . '<='] = $date_to->setTime(23, 59, 59); | |
| 139 | + $dataCondition[$this->prepareColumn($filter->getColumn()).'<='] = $date_to->setTime(23, 59, 59); | |
| 140 | 140 | } | 
| 141 | 141 | |
| 142 | 142 |  		if (!empty($dataCondition)) { | 
| @@ -160,11 +160,11 @@ discard block | ||
| 160 | 160 | $dataCondition = []; | 
| 161 | 161 | |
| 162 | 162 |  		if ($value_from) { | 
| 163 | - $dataCondition[$this->prepareColumn($filter->getColumn()) . '>='] = $value_from; | |
| 163 | + $dataCondition[$this->prepareColumn($filter->getColumn()).'>='] = $value_from; | |
| 164 | 164 | } | 
| 165 | 165 | |
| 166 | 166 |  		if ($value_to) { | 
| 167 | - $dataCondition[$this->prepareColumn($filter->getColumn()) . '<='] = $value_to; | |
| 167 | + $dataCondition[$this->prepareColumn($filter->getColumn()).'<='] = $value_to; | |
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | 170 |  		if (!empty($dataCondition)) { | 
| @@ -308,7 +308,7 @@ discard block | ||
| 308 | 308 | private function prepareColumn($column) | 
| 309 | 309 |  	{ | 
| 310 | 310 |  	if (Strings::contains($column, '.')) { | 
| 311 | -		return 'this->' . str_replace('.', '->', $column); | |
| 311 | +		return 'this->'.str_replace('.', '->', $column); | |
| 312 | 312 | } | 
| 313 | 313 | return $column; | 
| 314 | 314 | } | 
| @@ -334,10 +334,10 @@ discard block | ||
| 334 | 334 | } | 
| 335 | 335 | $sql = 'SELECT '; | 
| 336 | 336 |  		foreach ($this->aggregations as $column => $aggregation_type) { | 
| 337 | -			$sql .= $aggregation_type . '(' . $column . ') as ' . $column . ','; | |
| 337 | +			$sql .= $aggregation_type.'('.$column.') as '.$column.','; | |
| 338 | 338 | } | 
| 339 | 339 | |
| 340 | - $sql = rtrim($sql, ',') . ' FROM ( ' . $this->data_source->getQueryBuilder()->getQuerySql() . ' ) as data'; | |
| 340 | + $sql = rtrim($sql, ',').' FROM ( '.$this->data_source->getQueryBuilder()->getQuerySql().' ) as data'; | |
| 341 | 341 | |
| 342 | 342 | $params = $this->data_source->getQueryBuilder()->getQueryParameters(); | 
| 343 | 343 | array_unshift($params, $sql); | 
| @@ -93,7 +93,7 @@ discard block | ||
| 93 | 93 | [$this->data, $filter->getValue()] | 
| 94 | 94 | ); | 
| 95 | 95 |  				} else { | 
| 96 | -					$this->data = array_filter($this->data, function ($row) use ($filter) { | |
| 96 | +					$this->data = array_filter($this->data, function($row) use ($filter) { | |
| 97 | 97 | return $this->applyFilter($row, $filter); | 
| 98 | 98 | }); | 
| 99 | 99 | } | 
| @@ -421,7 +421,7 @@ discard block | ||
| 421 | 421 | |
| 422 | 422 |  		foreach ($this->aggregations as $column => $aggregation_type) { | 
| 423 | 423 |  			if ($aggregation_type == ColumnAggregationFunction::$aggregation_type_avg) { | 
| 424 | - $result[$column] = $result[$column] / count($this->data); | |
| 424 | + $result[$column] = $result[$column] / count($this->data); | |
| 425 | 425 | } | 
| 426 | 426 | } | 
| 427 | 427 | return $result; | 
| @@ -146,7 +146,7 @@ | ||
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | /** | 
| 149 | - * @param array $columns | |
| 149 | + * @param Column\IColumn[] $columns | |
| 150 | 150 | * @return array|bool | 
| 151 | 151 | */ | 
| 152 | 152 | public function aggregationRow(array $columns) |