Completed
Push — master ( f571ad...af881e )
by Gorka
10s
created

DoctrineORMTaskSpecificationFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildFilterableSpecification() 0 23 2
1
<?php
2
3
/*
4
 * This file is part of the Kreta 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
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Infrastructure\Persistence\Doctrine\ORM\Project\Task;
16
17
use Kreta\SharedKernel\Domain\Model\Exception;
18
use Kreta\TaskManager\Domain\Model\Project\Task\TaskId;
19
use Kreta\TaskManager\Domain\Model\Project\Task\TaskPriority;
20
use Kreta\TaskManager\Domain\Model\Project\Task\TaskProgress;
21
use Kreta\TaskManager\Domain\Model\Project\Task\TaskSpecificationFactory;
22
23
class DoctrineORMTaskSpecificationFactory implements TaskSpecificationFactory
24
{
25
    public function buildFilterableSpecification(
26
        array $projectIds,
27
        $title,
28
        ? TaskId $parentId,
29
        ? TaskPriority $priority,
30
        ? TaskProgress $progress,
31
        int $offset = 0,
32
        int $limit = -1
33
    ) {
34
        if (empty($projectIds)) {
35
            throw new Exception('Needs at least one project id');
36
        }
37
38
        return new DoctrineORMFilterableSpecification(
39
            $projectIds,
40
            $title,
41
            $parentId,
42
            $priority,
43
            $progress,
44
            $offset,
45
            $limit
46
        );
47
    }
48
}
49