Failed Conditions
Push — master ( d2d721...8007f2 )
by Yo
02:30
created

LoggerAwareInitializer::initializeContext()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
namespace Yoanm\BehatUtilsExtension\Context\Initializer;
3
4
use Behat\Behat\Context\Context;
5
use Behat\Behat\Context\Initializer\ContextInitializer;
6
use Psr\Log\LoggerInterface;
7
use Yoanm\BehatUtilsExtension\Context\LoggerAwareInterface;
8
9
/**
10
 * Class LoggerAwareInitializer
11
 */
12
class LoggerAwareInitializer implements ContextInitializer
13
{
14
    /** @var LoggerInterface */
15
    private $logger;
16
17
    /**
18
     * @param LoggerInterface $logger
19
     */
20 2
    public function __construct(LoggerInterface $logger)
21
    {
22 2
        $this->logger = $logger;
23 2
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 2
    public function initializeContext(Context $context)
29
    {
30 2
        if (!$context instanceof LoggerAwareInterface) {
31 1
            return;
32
        }
33
34 1
        $context->setBehatLogger($this->logger);
35 1
    }
36
}
37