Completed
Pull Request — master (#362)
by Paul
08:59 queued 02:20
created

VictoireCollector   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 39
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A collect() 0 6 1
A addCachedWidget() 0 4 1
A getCachedWidgetCount() 0 4 1
A getName() 0 4 1
1
<?php
2
namespace Victoire\Bundle\CoreBundle\DataCollector;
3
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
8
use Victoire\Bundle\WidgetBundle\Entity\Widget;
9
10
/**
11
 * This collector displays a victoire element in toolbar
12
 */
13
class VictoireCollector extends DataCollector
14
{
15
    protected $cachedWidgets = array();
16
17
    /**
18
     * @param Request         $request
19
     * @param Response        $response
20
     * @param \Exception|null $exception
21
     */
22
    public function collect(Request $request, Response $response, \Exception $exception = null)
23
    {
24
        $this->data = array(
25
            'cachedWidgetCount' => count($this->cachedWidgets),
26
        );
27
    }
28
29
    /**
30
     * Add a widget to the stack of cached widgets
31
     * @param Widget $widget
32
     */
33
    public function addCachedWidget(Widget $widget)
34
    {
35
        $this->cachedWidgets[] = $widget;
36
    }
37
38
    /**
39
     * @return mixed
40
     */
41
    public function getCachedWidgetCount()
42
    {
43
        return $this->data['cachedWidgetCount'];
44
    }
45
46
    public function getName()
47
    {
48
        return 'victoire_core.victoire_collector';
49
    }
50
51
}
52