GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 1dd304...6c6f43 )
by Mewes
06:12
created

CellWrapper::start()   A

Complexity

Conditions 5
Paths 7

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 5.0061

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 15
cts 16
cp 0.9375
rs 9.1608
c 0
b 0
f 0
cc 5
nc 7
nop 3
crap 5.0061
1
<?php
2
3
namespace MewesK\TwigSpreadsheetBundle\Wrapper;
4
5
use PhpOffice\PhpSpreadsheet\Cell\Cell;
6
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
7
8
/**
9
 * Class CellWrapper.
10
 */
11
class CellWrapper extends BaseWrapper
12
{
13
    /**
14
     * @var SheetWrapper
15
     */
16
    protected $sheetWrapper;
17
18
    /**
19
     * @var Cell|null
20
     */
21
    protected $object;
22
23
    /**
24
     * CellWrapper constructor.
25
     *
26
     * @param array             $context
27
     * @param \Twig_Environment $environment
28
     * @param SheetWrapper      $sheetWrapper
29
     */
30 112
    public function __construct(array $context, \Twig_Environment $environment, SheetWrapper $sheetWrapper)
31
    {
32 112
        parent::__construct($context, $environment);
33
34 112
        $this->sheetWrapper = $sheetWrapper;
35
36 112
        $this->object = null;
37 112
    }
38
39
    /**
40
     * @param int|null   $index
41
     * @param mixed|null $value
42
     * @param array      $properties
43
     *
44
     * @throws \InvalidArgumentException
45
     * @throws \LogicException
46
     * @throws \PhpOffice\PhpSpreadsheet\Exception
47
     * @throws \RuntimeException
48
     */
49 73
    public function start(int $index = null, $value = null, array $properties = [])
50
    {
51 73
        if ($this->sheetWrapper->getObject() === null) {
52
            throw new \LogicException();
53
        }
54
55 73
        if ($index === null) {
56 73
            $this->sheetWrapper->increaseColumn();
57
        } else {
58 13
            $this->sheetWrapper->setColumn($index);
59
        }
60
61 73
        $this->object = $this->sheetWrapper->getObject()->getCellByColumnAndRow($this->sheetWrapper->getColumn(),
62 73
            $this->sheetWrapper->getRow());
63
64 73
        if ($value !== null) {
65 73
            if (isset($properties['dataType'])) {
66 7
                $this->object->setValueExplicit($value, $properties['dataType']);
67
            } else {
68 73
                $this->object->setValue($value);
69
            }
70
        }
71
72 73
        $this->parameters['value'] = $value;
73 73
        $this->parameters['properties'] = $properties;
74
75 73
        $this->setProperties($properties);
76 73
    }
77
78 73
    public function end()
79
    {
80 73
        $this->object = null;
81 73
        $this->parameters = [];
82 73
    }
83
84
    /**
85
     * @return Cell|null
86
     */
87
    public function getObject()
88
    {
89
        return $this->object;
90
    }
91
92
    /**
93
     * @param Cell|null $object
94
     */
95
    public function setObject(Cell $object = null)
96
    {
97
        $this->object = $object;
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     *
103
     * @throws \PhpOffice\PhpSpreadsheet\Exception
104
     */
105
    protected function configureMappings(): array
106
    {
107
        return [
108
            'break' => function ($value) { $this->sheetWrapper->getObject()->setBreak($this->object->getCoordinate(), $value); },
109
            'dataType' => function ($value) { $this->object->setDataType($value); },
110
            'dataValidation' => [
111
                'allowBlank' => function ($value) { $this->object->getDataValidation()->setAllowBlank($value); },
112
                'error' => function ($value) { $this->object->getDataValidation()->setError($value); },
113
                'errorStyle' => function ($value) { $this->object->getDataValidation()->setErrorStyle($value); },
114
                'errorTitle' => function ($value) { $this->object->getDataValidation()->setErrorTitle($value); },
115
                'formula1' => function ($value) { $this->object->getDataValidation()->setFormula1($value); },
116
                'formula2' => function ($value) { $this->object->getDataValidation()->setFormula2($value); },
117
                'operator' => function ($value) { $this->object->getDataValidation()->setOperator($value); },
118
                'prompt' => function ($value) { $this->object->getDataValidation()->setPrompt($value); },
119
                'promptTitle' => function ($value) { $this->object->getDataValidation()->setPromptTitle($value); },
120
                'showDropDown' => function ($value) { $this->object->getDataValidation()->setShowDropDown($value); },
121
                'showErrorMessage' => function ($value) { $this->object->getDataValidation()->setShowErrorMessage($value); },
122
                'showInputMessage' => function ($value) { $this->object->getDataValidation()->setShowInputMessage($value); },
123
                'type' => function ($value) { $this->object->getDataValidation()->setType($value); },
124
            ],
125 112
            'merge' => function ($value) {
126 2
                if (\is_int($value)) {
127 2
                    $value = Coordinate::stringFromColumnIndex($value).$this->sheetWrapper->getRow();
128
                }
129 2
                $this->sheetWrapper->getObject()->mergeCells(sprintf('%s:%s', $this->object->getCoordinate(), $value));
130 112
            },
131
            'style' => function ($value) { $this->sheetWrapper->getObject()->getStyle($this->object->getCoordinate())->applyFromArray($value); },
132
            'url' => function ($value) { $this->object->getHyperlink()->setUrl($value); },
133
        ];
134
    }
135
}
136