DataPointIndex   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 26 2
1
<?php
2
3
/*
4
 * This file is part of the ReportBundle package
5
 * 
6
 * (c) symball <http://simonball.me>
7
 * 
8
 * For the full copyright and license information, please view the LICENSE file 
9
 * that was distributed with this source code.
10
 */
11
12
namespace Symball\ReportBundle\Patterns;
13
14
use Symball\ReportBundle\Interfaces\PatternInterface;
15
use Symball\ReportBundle\Service\ReportBuilder;
16
17
/**
18
 * This pattern draws the data point headings along the x axis
19
 *
20
 * @author Simon Ball <simonball at simonball dot me>
21
 */
22
class DataPointIndex implements PatternInterface
23
{
24
    /**
25
     * The main function for creating the data point index
26
     *
27
     * @param ReportBuilder $context
28
     */
29
    public function run(ReportBuilder &$context)
30
    {
31
        $nav = $context->nav();
32
        $meta = $context->meta();
33
34
        $nav
35
        ->reset('initial')
36
        ->left();
37
38
        foreach ($meta->getDataSet() as $key => $options) {
39
            $context->write($key);
40
            $context->style('bg', (string) $nav);
41
42
            $nav->axisXMove();
43
        }
44
45
        // Draw the edge line
46
        $start = $nav->coord('current', 'initial');
47
        $end = $nav->coord('current', ($nav->row() - 1));
48
        $coordString = $start.':'.$end;
49
        
50
        $context->style('border', $coordString, ['edge' => 'right']);
51
        $context->style('align', $coordString, ['edge' => 'right']);
52
53
        $nav->reset('set');
54
    }
55
}
56