for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/
namespace Cycle\ORM\Promise;
use Cycle\ORM\ORMInterface;
* Promises the selection of the
class PromiseMany implements PromiseInterface
{
/** @var ORMInterface @internal */
private $orm;
/** @var string */
private $target;
/** @var array */
private $query = [];
private $where = [];
private $resolved = [];
* @param ORMInterface $orm
* @param string $target
* @param array $query
* @param array $where
public function __construct(ORMInterface $orm, string $target, array $query = [], array $where = [])
$this->orm = $orm;
$this->target = $target;
$this->query = $query;
$this->where = $where;
}
* @inheritdoc
public function __loaded(): bool
return empty($this->orm);
public function __role(): string
return $this->target;
public function __scope(): array
return $this->query;
public function __resolve()
if (is_null($this->orm)) {
return $this->resolved;
foreach ($this->orm->getRepository($this->target)->findAll($this->query + $this->where) as $item) {
$this->resolved[] = $item;
$this->orm = null;