Code Duplication    Length = 33-33 lines in 2 locations

src/DoctrineSpecification/QueryFactory/AndXFactory.php 1 location

@@ 17-49 (lines=33) @@
14
 *
15
 * @author gbprod <[email protected]>
16
 */
17
class AndXFactory implements Factory
18
{
19
    /**
20
     * @var Registry
21
     */
22
    private $registry;
23
24
    /**
25
     * @param Registry $registry
26
     */
27
    public function __construct(Registry $registry)
28
    {
29
        $this->registry = $registry;
30
    }
31
32
    /**
33
     * {inheritdoc}
34
     */
35
    public function create(Specification $spec, QueryBuilder $qb)
36
    {
37
        if (!$spec instanceof AndX) {
38
            throw new \InvalidArgumentException();
39
        }
40
41
        $firstPartFactory = $this->registry->getFactory($spec->getFirstPart());
42
        $secondPartFactory = $this->registry->getFactory($spec->getSecondPart());
43
44
        return $qb->expr()->andX(
45
            $firstPartFactory->create($spec->getFirstPart(), $qb),
46
            $secondPartFactory->create($spec->getSecondPart(), $qb)
47
        );
48
    }
49
}
50

src/DoctrineSpecification/QueryFactory/OrXFactory.php 1 location

@@ 17-49 (lines=33) @@
14
 *
15
 * @author gbprod <[email protected]>
16
 */
17
class OrXFactory implements Factory
18
{
19
    /**
20
     * @var Registry
21
     */
22
    private $registry;
23
24
    /**
25
     * @param Registry $registry
26
     */
27
    public function __construct(Registry $registry)
28
    {
29
        $this->registry = $registry;
30
    }
31
32
    /**
33
     * {inheritdoc}
34
     */
35
    public function create(Specification $spec, QueryBuilder $qb)
36
    {
37
        if (!$spec instanceof OrX) {
38
            throw new \InvalidArgumentException();
39
        }
40
41
        $firstPartFactory  = $this->registry->getFactory($spec->getFirstPart());
42
        $secondPartFactory = $this->registry->getFactory($spec->getSecondPart());
43
44
        return $qb->expr()->orx(
45
            $firstPartFactory->create($spec->getFirstPart(), $qb),
46
            $secondPartFactory->create($spec->getSecondPart(), $qb)
47
        );
48
    }
49
}
50