Completed
Push — master ( 36152a...1c7656 )
by Beñat
02:48
created

AllFilesHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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\Application\Query;
14
15
use BenGorFile\File\Application\DataTransformer\FileDataTransformer;
16
use BenGorFile\File\Domain\Model\File;
17
use BenGorFile\File\Domain\Model\FileRepository;
18
19
/**
20
 * All files query handler.
21
 *
22
 * @author Beñat Espiña <[email protected]>
23
 */
24
class AllFilesHandler
25
{
26
    /**
27
     * The file data transformer.
28
     *
29
     * @var FileDataTransformer
30
     */
31
    private $dataTransformer;
32
33
    /**
34
     * The file repository.
35
     *
36
     * @var FileRepository
37
     */
38
    private $repository;
39
40
    /**
41
     * Constructor.
42
     *
43
     * @param FileRepository      $aRepository      The file repository
44
     * @param FileDataTransformer $aDataTransformer The file data transformer
45
     */
46
    public function __construct(FileRepository $aRepository, FileDataTransformer $aDataTransformer)
47
    {
48
        $this->repository = $aRepository;
49
        $this->dataTransformer = $aDataTransformer;
50
    }
51
52
    /**
53
     * Handles the given query.
54
     *
55
     * @param AllFilesQuery $aQuery The query
56
     *
57
     * @return mixed
58
     */
59
    public function __invoke(AllFilesQuery $aQuery)
0 ignored issues
show
Unused Code introduced by
The parameter $aQuery is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
    {
61
        $files = $this->repository->all();
62
63
        $result = array_map(function (File $file) {
64
            $this->dataTransformer->write($file);
65
66
            return $this->dataTransformer->read();
67
        }, $files);
68
69
        return $result;
70
    }
71
}
72