eee
This commit is contained in:
+32
-33
@@ -16,45 +16,44 @@ use Exception;
|
||||
class CollectionIterator extends \ArrayIterator
|
||||
{
|
||||
|
||||
private ModelInterface|string $model;
|
||||
private ModelInterface|string $model;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CollectionIterator constructor.
|
||||
* @param $model
|
||||
* @param array $array
|
||||
* @param int $flags
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($model, array $array = [], int $flags = 0)
|
||||
{
|
||||
$this->model = $model;
|
||||
parent::__construct($array, $flags);
|
||||
}
|
||||
/**
|
||||
* CollectionIterator constructor.
|
||||
* @param $model
|
||||
* @param array $array
|
||||
* @param int $flags
|
||||
* @throws
|
||||
*/
|
||||
public function __construct($model, array $array = [], int $flags = 0)
|
||||
{
|
||||
$this->model = $model;
|
||||
parent::__construct($array, $flags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $current
|
||||
* @return ModelInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function newModel($current): ModelInterface
|
||||
{
|
||||
return $this->model->populates($current);
|
||||
}
|
||||
/**
|
||||
* @param $current
|
||||
* @return ModelInterface
|
||||
* @throws
|
||||
*/
|
||||
protected function newModel($current): ModelInterface
|
||||
{
|
||||
return $this->model->populates($current);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function current(): ModelInterface
|
||||
{
|
||||
if (is_array($current = parent::current())) {
|
||||
$current = $this->newModel($current);
|
||||
}
|
||||
return $current;
|
||||
}
|
||||
/**
|
||||
* @throws
|
||||
*/
|
||||
public function current(): ModelInterface
|
||||
{
|
||||
if (is_array($current = parent::current())) {
|
||||
$current = $this->newModel($current);
|
||||
}
|
||||
return $current;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user