Skip to content

Commit 4f76354

Browse files
committed
Fixed various issues reported by travis-ci
1 parent 0b80375 commit 4f76354

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/Builder/Traits/ConditionDefinition.php renamed to src/Builder/Helpers/ConditionAddHelper.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
11
<?php
2-
namespace Kir\MySQL\Builder\Traits;
2+
namespace Kir\MySQL\Builder\Helpers;
33

44
use Closure;
55
use Kir\MySQL\Builder\Expr\OptionalExpression;
66

7-
trait ConditionDefinition {
7+
abstract class ConditionAddHelper {
88
/**
99
* @param Closure $addFn
1010
* @param string|array|object|OptionalExpression $expression
1111
* @param mixed[] $args
12-
* @return $this
1312
*/
14-
protected function addCondition(Closure $addFn, $expression, ...$args) {
13+
public static function addCondition(Closure $addFn, $expression, ...$args) {
1514
if($expression instanceof OptionalExpression) {
1615
if($expression->isValid()) {
1716
$addFn($expression->getExpression(), $expression->getValue());
1817
}
1918
} elseif(is_object($expression)) {
20-
$this->addAsArray($addFn, (array) $expression, $args);
19+
self::addAsArray($addFn, (array) $expression, $args);
2120
} elseif(is_array($expression)) {
22-
$this->addAsArray($addFn, $expression, $args);
21+
self::addAsArray($addFn, $expression, $args);
2322
} else {
2423
$addFn($expression, $args);
2524
}
26-
return $this;
2725
}
2826

2927
/**
3028
* @param Closure $addFn
3129
* @param array $expression
3230
* @param array $args
3331
*/
34-
private function addAsArray(Closure $addFn, array $expression, array $args) {
32+
private static function addAsArray(Closure $addFn, array $expression, array $args) {
3533
if(count($expression) > 0) {
3634
$addFn($expression, $args);
3735
}

src/Builder/Traits/HavingBuilder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
namespace Kir\MySQL\Builder\Traits;
33

44
use Kir\MySQL\Builder\Expr\OptionalExpression;
5+
use Kir\MySQL\Builder\Helpers\ConditionAddHelper;
56
use Kir\MySQL\Builder\Internal\ConditionBuilder;
67

78
trait HavingBuilder {
89
use AbstractDB;
9-
use ConditionDefinition;
1010

1111
/** @var array[] */
1212
private $having = [];
@@ -18,14 +18,15 @@ trait HavingBuilder {
1818
*/
1919
public function having($expression, ...$args) {
2020
$fn = function (...$args) { $this->having[] = $args; };
21-
return $this->addCondition($fn, $expression, ...$args);
21+
ConditionAddHelper::addCondition($fn, $expression, ...$args);
22+
return $this;
2223
}
2324

2425
/**
2526
* @param string $query
2627
* @return string
2728
*/
28-
protected function buildHavingConditions($query) {
29+
protected function buildHavingConditions(string $query) {
2930
return ConditionBuilder::build($this->db(), $query, $this->having, 'HAVING');
3031
}
3132
}

src/Builder/Traits/WhereBuilder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
namespace Kir\MySQL\Builder\Traits;
33

44
use Kir\MySQL\Builder\Expr\OptionalExpression;
5+
use Kir\MySQL\Builder\Helpers\ConditionAddHelper;
56
use Kir\MySQL\Builder\Internal\ConditionBuilder;
67

78
trait WhereBuilder {
89
use AbstractDB;
9-
use ConditionDefinition;
1010

1111
/** @var array[] */
1212
private $where = [];
@@ -18,14 +18,15 @@ trait WhereBuilder {
1818
*/
1919
public function where($expression, ...$args) {
2020
$fn = function (...$args) { $this->where[] = $args; };
21-
return $this->addCondition($fn, $expression, ...$args);
21+
ConditionAddHelper::addCondition($fn, $expression, ...$args);
22+
return $this;
2223
}
2324

2425
/**
2526
* @param string $query
2627
* @return string
2728
*/
28-
protected function buildWhereConditions($query) {
29+
protected function buildWhereConditions(string $query) {
2930
return ConditionBuilder::build($this->db(), $query, $this->where, 'WHERE');
3031
}
3132
}

0 commit comments

Comments
 (0)