Border::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 3
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
/**
13
 * Create a border along a range of cells
14
 *
15
 * @author Simon Ball <simonball at simonball dot me>
16
 */
17
18
namespace Symball\ReportBundle\Styles;
19
20
use Symball\ReportBundle\Service\ReportBuilder;
21
use Symball\ReportBundle\Interfaces\StyleInterface; 
22
23
class Border implements StyleInterface
24
{
25
    /**
26
     * Take a coordinate range and paint a border along it
27
     *
28
     * @param ReportBuilder $context
29
     * @param string        $coordString
30
     * @param array         $options
31
     * @return type
32
     * @throws \InvalidArgumentException if options array is missing edge
33
     */
34
    public function run(ReportBuilder &$context, $coordString, $options)
35
    {
36
        if (!isset($options['edge'])) {
37
            throw new \InvalidArgumentException('Must set edge to use in options array');
38
        }
39
40
        if (!isset($options['thickness'])) {
41
            $options['thickness'] = $options['default_line_thickness'];
42
        }
43
        $context->sheet()
44
        ->getStyle($coordString)
45
        ->applyFromArray(
46
            ['borders' => [
47
                $options['edge'] => [
48
            'style' => $options['thickness']]]]
49
        );
50
    }
51
}
52