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

GitIgnoreExtractorHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 37
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A extract() 0 6 1
A handle() 0 4 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