Test Failed
Push — master ( 9196b6...62d342 )
by Ivan
02:35
created

NavigationProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 24
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A accept() 0 8 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Everlution\Navigation\Provider;
6
7
use Everlution\Navigation\Factory\ItemFactory;
8
use Everlution\Navigation\RootNavigationItem;
9
10
/**
11
 * Class NavigationProvider.
12
 * @author Ivan Barlog <[email protected]>
13
 */
14
class NavigationProvider implements Provider
15
{
16
    /** @var ItemFactory */
17
    private $factory;
18
19
    public function __construct(ItemFactory $factory)
20
    {
21
        $this->factory = $factory;
22
    }
23
24
    /**
25
     * @param string $identifier
26
     * @param DataProvider $dataProvider
27
     * @return RootNavigationItem|null
28
     */
29
    public function accept(string $identifier, DataProvider &$dataProvider)
30
    {
31
        if (false === $dataProvider->canHandle($identifier)) {
32
            return null;
33
        }
34
35
        return $this->factory->build($dataProvider->getData($identifier));
36
    }
37
}
38