AggregateEventApplyHandlerValidator::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
/******************************************************************************
3
 * Copyright (c) 2017 Constantin Galbenu <[email protected]>             *
4
 ******************************************************************************/
5
6
namespace Gica\Cqrs\CodeGeneration;
7
8
use Gica\CodeAnalysis\AggregateEventHandlersValidator;
9
use Gica\Cqrs\Aggregate\CodeAnalysis\ListenerClassValidator\OnlyAggregateByName;
10
use Psr\Log\LoggerInterface;
11
12
class AggregateEventApplyHandlerValidator
13
{
14
    /**
15
     * @var LoggerInterface
16
     */
17
    private $logger;
18
19 1
    public function __construct(
20
        LoggerInterface $logger = null
21
    )
22
    {
23 1
        $this->logger = $logger;
24 1
    }
25
26 1
    public function validate(
27
        \Iterator $files
28
    )
29
    {
30 1
        $validator = new AggregateEventHandlersValidator(
31 1
            new OnlyAggregateByName());
32
33 1
        $validator->validateEventHandlers($files);
34
35 1
        if ($this->logger) {
36 1
            $this->logger->info("Aggregate event handlers are valid");
37
        }
38
    }
39
}