Completed
Push — master ( 835840...ce2316 )
by Pablo
02:59
created

GitIgnoreExtractorHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PhpGitHooks\Module\Git\Contract\Query;
4
5
use Bruli\EventBusBundle\QueryBus\QueryHandlerInterface;
6
use Bruli\EventBusBundle\QueryBus\QueryInterface;
7
use PhpGitHooks\Module\Git\Contract\Response\GitIgnoreDataResponse;
8
use PhpGitHooks\Module\Git\Model\ReaderInterface;
9
10
class GitIgnoreExtractorHandler implements QueryHandlerInterface
11
{
12
    /**
13
     * @var ReaderInterface
14
     */
15
    private $reader;
16
17
    /**
18
     * GitIgnoreExtractor constructor.
19
     *
20
     * @param ReaderInterface $reader
21
     */
22 1
    public function __construct(ReaderInterface $reader)
23
    {
24 1
        $this->reader = $reader;
25 1
    }
26
27
    /**
28
     * @return GitIgnoreDataResponse
29
     */
30 1
    private function extract()
31
    {
32 1
        $content = $this->reader->read();
33
34 1
        return new GitIgnoreDataResponse($content);
35
    }
36
37
    /**
38
     * @param QueryInterface $query
39
     *
40
     * @return GitIgnoreDataResponse|GitIgnoreExtractor
41
     */
42 1
    public function handle(QueryInterface $query)
43
    {
44 1
        return $this->extract();
45
    }
46
}
47