XlsRowWrapper   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B start() 0 15 5
A end() 0 4 1
1
<?php
2
3
namespace MewesK\TwigExcelBundle\Wrapper;
4
use Twig_Environment;
5
6
/**
7
 * Class XlsSheetWrapper
8
 *
9
 * @package MewesK\TwigExcelBundle\Wrapper
10
 */
11
class XlsRowWrapper extends AbstractWrapper
12
{
13
    /**
14
     * @var array
15
     */
16
    protected $context;
17
    /**
18
     * @var Twig_Environment
19
     */
20
    protected $environment;
21
    /**
22
     * @var XlsSheetWrapper
23
     */
24
    protected $sheetWrapper;
25
26
    /**
27
     * XlsRowWrapper constructor.
28
     * @param array $context
29
     * @param Twig_Environment $environment
30
     * @param XlsSheetWrapper $sheetWrapper
31
     */
32
    public function __construct(array $context, Twig_Environment $environment, XlsSheetWrapper $sheetWrapper)
33
    {
34
        $this->context = $context;
35
        $this->environment = $environment;
36
        $this->sheetWrapper = $sheetWrapper;
37
    }
38
39
    /**
40
     * @param null|int $index
41
     * @throws \LogicException
42
     */
43
    public function start($index = null)
44
    {
45
        if ($this->sheetWrapper->getObject() === null) {
46
            throw new \LogicException();
47
        }
48
        if ($index !== null && !is_int($index)) {
49
            throw new \InvalidArgumentException('Invalid index');
50
        }
51
52
        if ($index === null) {
53
            $this->sheetWrapper->increaseRow();
54
        } else {
55
            $this->sheetWrapper->setRow($index);
56
        }
57
    }
58
59
    public function end()
60
    {
61
        $this->sheetWrapper->setColumn(null);
62
    }
63
}
64