Completed
Push — master ( 557727...adef2f )
by Beñat
13s
created

SqlByNameSpecification   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildQuery() 0 7 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\File\Infrastructure\Persistence\Sql;
14
15
use BenGorFile\File\Domain\Model\FileName;
16
17
/**
18
 * @author Mikel Etxebarria <[email protected]>
19
 */
20
class SqlByNameSpecification implements SqlQuerySpecification
21
{
22
    private $name;
23
24
    public function __construct(FileName $aName)
25
    {
26
        $this->name = $aName;
27
    }
28
29
    public function buildQuery()
30
    {
31
        $query = 'SELECT * FROM file f WHERE f.name = :name AND f.extension = :extension';
32
        $parameters = [":name" => $this->name->name(), ":extension" => $this->name->extension()];
33
34
        return [$query, $parameters];
35
    }
36
}
37