Completed
Push — master ( 5bd0a6...5cfde8 )
by Kamil
20:21
created

FakeChannelCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 43
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getChannels() 0 4 1
A getCurrentChannel() 0 4 1
A collect() 0 3 1
A getName() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\ChannelBundle\Context\FakeChannel;
13
14
use Sylius\Component\Channel\Context\ChannelContextInterface;
15
use Sylius\Component\Channel\Model\ChannelInterface;
16
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
17
use Symfony\Component\HttpFoundation\Request;
18
use Symfony\Component\HttpFoundation\Response;
19
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
20
21
/**
22
 * @author Kamil Kokot <[email protected]>
23
 */
24
final class FakeChannelCollector extends DataCollector
25
{
26
    /**
27
     * @param ChannelRepositoryInterface $channelRepository
28
     * @param ChannelContextInterface $channelContext
29
     */
30
    public function __construct(ChannelRepositoryInterface $channelRepository, ChannelContextInterface $channelContext)
31
    {
32
        $this->data['channels'] = $channelRepository->findAll();
33
        $this->data['current_channel'] = $channelContext->getChannel();
34
    }
35
36
    /**
37
     * @return ChannelInterface[]
38
     */
39
    public function getChannels()
40
    {
41
        return $this->data['channels'];
42
    }
43
44
    /**
45
     * @return ChannelInterface
46
     */
47
    public function getCurrentChannel()
48
    {
49
        return $this->data['current_channel'];
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function collect(Request $request, Response $response, \Exception $exception = null)
56
    {
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function getName()
63
    {
64
        return 'sylius.context.channel.fake_channel.collector';
65
    }
66
}
67