Passed
Pull Request — master (#38)
by Christophe
05:14
created

EventsOutput::draw()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 10
ccs 4
cts 6
cp 0.6667
crap 2.1481
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace CMEN\GoogleChartsBundle\Output\Javascript;
4
5
use CMEN\GoogleChartsBundle\GoogleCharts\Events;
6
use CMEN\GoogleChartsBundle\Output\EventsOutputInterface;
7
8
class EventsOutput implements EventsOutputInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 4
    public function draw(Events $events, $chartName)
14
    {
15 4
        $js = '';
16
17 4
        foreach ($events->getListeners() as $listener) {
18
            $js .= 'google.visualization.events.addListener('.$chartName.", '".$listener->getType().
19
                "', ".$listener->getFunction().');';
20
        }
21
22 4
        return $js;
23
    }
24
}
25