Passed
Push — swp-252 ( bc0f1e )
by Rafał
190:48 queued 143:56
created

ContextDataCollector::collect()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 3
crap 2
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Template Engine Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\TemplateEngineBundle\DataCollector;
16
17
use SWP\Component\TemplatesSystem\Gimme\Context\Context;
18
use Symfony\Component\HttpFoundation\Request;
19
use Symfony\Component\HttpFoundation\Response;
20
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
21
22
class ContextDataCollector extends DataCollector
23
{
24
    /**
25
     * @var Context
26
     */
27
    protected $context;
28
29 70
    public function __construct($context)
30
    {
31 70
        $this->context = $context;
32 70
    }
33
34 2
    public function collect(Request $request, Response $response, \Exception $exception = null)
35
    {
36 2
        $this->data = [
37 2
            'currentPage' => null !== $this->context->getCurrentPage() ? get_object_vars($this->context->getCurrentPage()) : [],
38 2
            'registeredMeta' => $this->context->getRegisteredMeta(),
39
        ];
40 2
    }
41
42
    public function getData()
43
    {
44
        return $this->data;
45
    }
46
47 70
    public function getName()
48
    {
49 70
        return 'context_collector';
50
    }
51
}
52