for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of Hydrogen package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace RDS\Hydrogen\Processor\DatabaseProcessor;
use Doctrine\ORM\Mapping\ClassMetadata;
use RDS\Hydrogen\Processor\BuilderInterface;
use RDS\Hydrogen\Processor\ProcessorInterface;
use RDS\Hydrogen\Query;
* Class Builder
abstract class Builder implements BuilderInterface
{
* @var ProcessorInterface
protected $processor;
* @var ClassMetadata
protected $meta;
* Builder constructor.
* @param ClassMetadata $meta
* @param ProcessorInterface $processor
public function __construct(ClassMetadata $meta, ProcessorInterface $processor)
$this->meta = $meta;
$this->processor = $processor;
}
* @param string $entity
* @return ClassMetadata
protected function meta(string $entity): ClassMetadata
return $this->processor->getEntityManager()->getClassMetadata($entity);
* @param Query $query
* @return iterable
protected function execute(string $entity, Query $query): iterable
return $this->processor->getProcessor($entity)->getResult($query);
* @return \Generator
protected function nothing(): \Generator
if (false) {
yield;
* @param \Generator $generator
* @param \Closure $then
protected function extractResult(\Generator $generator, \Closure $then): \Generator
yield from $generator;
$then($generator->getReturn());