Skip to content

Commit e287267

Browse files
committed
refactor code
1 parent 7b15bf6 commit e287267

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

src/QueryEngine.php

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public function size()
399399
public function sum($column = null)
400400
{
401401
$this->prepare();
402-
$data = $this->toArray();
402+
$data = $this->_data;
403403

404404
$sum = 0;
405405
if (is_null($column)) {
@@ -427,7 +427,7 @@ public function sum($column = null)
427427
public function max($column = null)
428428
{
429429
$this->prepare();
430-
$data = $this->toArray();
430+
$data = $this->_data;
431431
if (!is_null($column)) {
432432
$values = [];
433433
foreach ($data as $val) {
@@ -450,7 +450,7 @@ public function max($column = null)
450450
public function min($column = null)
451451
{
452452
$this->prepare();
453-
$data = $this->toArray();
453+
$data = $this->_data;
454454

455455
if (!is_null($column)) {
456456
$values = [];
@@ -696,36 +696,12 @@ public function map(callable $fn)
696696
$data = [];
697697

698698
foreach ($this->_data as $key => $val) {
699-
$data[$key] = $fn($val);
699+
$data[] = $fn($key, $val);
700700
}
701701

702702
return $this->makeResult($data);
703703
}
704704

705-
/**
706-
* pipe send output in next pipe
707-
*
708-
* @param callable $fn
709-
* @param string|null $class
710-
* @return object|array
711-
* @throws ConditionNotAllowedException
712-
* @deprecated 2.0.0
713-
*/
714-
public function pipe(callable $fn, $class = null)
715-
{
716-
$this->prepare();
717-
718-
if (is_string($fn) && !is_null($class)) {
719-
$instance = new $class;
720-
721-
$this->_data = call_user_func_array([$instance, $fn], [$this]);
722-
return $this;
723-
}
724-
725-
$this->_data = $fn($this);
726-
return $this;
727-
}
728-
729705
/**
730706
* filtered each element of prepared data
731707
*

0 commit comments

Comments
 (0)