DoctrineORMByNameSpecification   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildQuery() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\DoctrineORMBridge\Infrastructure\Persistence;
14
15
use BenGorFile\File\Domain\Model\FileName;
16
use Doctrine\ORM\QueryBuilder;
17
18
/**
19
 * @author Beñat Espiña <[email protected]>
20
 */
21
class DoctrineORMByNameSpecification implements DoctrineORMQuerySpecification
22
{
23
    private $name;
24
25
    public function __construct(FileName $aName)
26
    {
27
        $this->name = $aName;
28
    }
29
30
    public function buildQuery(QueryBuilder $queryBuilder)
31
    {
32
        return $queryBuilder
33
            ->select('f')
34
            ->where($queryBuilder->expr()->eq('f.name.name', ':name'))
35
            ->andWhere($queryBuilder->expr()->eq('f.name.extension', ':extension'))
36
            ->setParameter('name', $this->name->name())
37
            ->setParameter('extension', $this->name->extension())
38
            ->getQuery();
39
    }
40
}
41