Skip to content

Commit

Permalink
Revert "[update] introduce and use Scope::create"
Browse files Browse the repository at this point in the history
This reverts commit 030b5e0.
  • Loading branch information
mvorisek committed Aug 8, 2020
1 parent 7db95b1 commit d12f1cc
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions src/Model/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ public function __clone()
*/
public function addCondition($field, $operator = null, $value = null)
{
$this->add(static::create(...func_get_args()));
if (func_num_args() === 1 && $field instanceof Scope\AbstractScope) {
$condition = $field;
} elseif (func_num_args() === 1 && is_array($field)) {
$condition = static::createAnd(func_get_args());
} else {
$condition = new Scope\Condition(...func_get_args());
}

$this->add($condition);

return $this;
}
Expand Down Expand Up @@ -189,28 +197,6 @@ public function toWords(Model $model = null): string
return implode($glue, $parts);
}

/**
* Creates the simplest scope object based on arguments.
*
* @param Scope\AbstractScope|string|array|\atk4\data\Field $field
* @param string $operator
* @param mixed $value
*
* @return Scope\AbstractScope
*/
public static function create($field, $operator = null, $value = null)
{
if (func_num_args() === 1 && $field instanceof Scope\AbstractScope) {
$scope = $field;
} elseif (func_num_args() === 1 && is_array($field)) {
$scope = static::createAnd(func_get_args());
} else {
$scope = new Scope\Condition(...func_get_args());
}

return $scope;
}

/**
* @return static
*/
Expand Down

0 comments on commit d12f1cc

Please sign in to comment.