Failed Conditions
Branch feature/init (0e876c)
by Yo
04:41 queued 01:07
created

LoggerAwareInitializer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 25
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A initializeContext() 0 8 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
    public function __construct(LoggerInterface $logger)
21
    {
22
        $this->logger = $logger;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function initializeContext(Context $context)
29
    {
30
        if (!$context instanceof LoggerAwareInterface) {
31
            return;
32
        }
33
34
        $context->setBehatLogger($this->logger);
35
    }
36
}
37