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 ( 3e189a...03d551 )
by Mewes
15:04
created

PhpSpreadsheetWrapper::setCellValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace MewesK\TwigSpreadsheetBundle\Wrapper;
4
5
/**
6
 * Class PhpSpreadsheetWrapper.
7
 */
8
class PhpSpreadsheetWrapper
9
{
10
    /**
11
     * @var string
12
     */
13
    const INSTANCE_KEY = '_tsb';
14
15
    /**
16
     * Copies the PhpSpreadsheetWrapper instance from 'varargs' to '_tsb'. This is necessary for all Twig code running
17
     * in sub-functions (e.g. block, macro, ...) since the root context is lost. To fix the sub-context a reference to
18
     * the PhpSpreadsheetWrapper instance is included in all function calls.
19
     *
20
     * @param array $context
21
     *
22
     * @return array
23
     */
24 106
    public static function fixContext(array $context): array
25
    {
26 106
        if (!isset($context[self::INSTANCE_KEY]) && isset($context['varargs']) && \is_array($context['varargs'])) {
27 3
            foreach ($context['varargs'] as $arg) {
28 3
                if ($arg instanceof self) {
29 3
                    $context[self::INSTANCE_KEY] = $arg;
30 3
                    break;
31
                }
32
            }
33
        }
34 106
        return $context;
35
    }
36
37
    /**
38
     * @var DocumentWrapper
39
     */
40
    private $documentWrapper;
41
    /**
42
     * @var SheetWrapper
43
     */
44
    private $sheetWrapper;
45
    /**
46
     * @var RowWrapper
47
     */
48
    private $rowWrapper;
49
    /**
50
     * @var CellWrapper
51
     */
52
    private $cellWrapper;
53
    /**
54
     * @var HeaderFooterWrapper
55
     */
56
    private $headerFooterWrapper;
57
    /**
58
     * @var DrawingWrapper
59
     */
60
    private $drawingWrapper;
61
62
    /**
63
     * PhpSpreadsheetWrapper constructor.
64
     *
65
     * @param array             $context
66
     * @param \Twig_Environment $environment
67
     * @param array             $attributes
68
     */
69 118
    public function __construct(array $context, \Twig_Environment $environment, array $attributes = [])
70
    {
71 118
        $this->documentWrapper = new DocumentWrapper($context, $environment, $attributes);
72 118
        $this->sheetWrapper = new SheetWrapper($context, $environment, $this->documentWrapper);
73 118
        $this->rowWrapper = new RowWrapper($context, $environment, $this->sheetWrapper);
74 118
        $this->cellWrapper = new CellWrapper($context, $environment, $this->sheetWrapper);
75 118
        $this->headerFooterWrapper = new HeaderFooterWrapper($context, $environment, $this->sheetWrapper);
76 118
        $this->drawingWrapper = new DrawingWrapper($context, $environment, $this->sheetWrapper, $this->headerFooterWrapper, $attributes);
77 118
    }
78
79
    /**
80
     * @return int|null
81
     */
82 4
    public function getCurrentColumn()
83
    {
84 4
        return $this->sheetWrapper->getColumn();
85
    }
86
87
    /**
88
     * @return int|null
89
     */
90 4
    public function getCurrentRow()
91
    {
92 4
        return $this->sheetWrapper->getRow();
93
    }
94
95
    /**
96
     * @param array $properties
97
     *
98
     * @throws \PhpOffice\PhpSpreadsheet\Exception
99
     * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
100
     * @throws \RuntimeException
101
     */
102 118
    public function startDocument(array $properties = [])
103
    {
104 118
        $this->documentWrapper->start($properties);
105 118
    }
106
107
    /**
108
     * @throws \RuntimeException
109
     * @throws \LogicException
110
     * @throws \InvalidArgumentException
111
     * @throws \PhpOffice\PhpSpreadsheet\Exception
112
     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
113
     * @throws \Symfony\Component\Filesystem\Exception\IOException
114
     */
115 110
    public function endDocument()
116
    {
117 110
        $this->documentWrapper->end();
118 110
    }
119
120
    /**
121
     * @param int|string|null $index
122
     * @param array $properties
123
     *
124
     * @throws \LogicException
125
     * @throws \PhpOffice\PhpSpreadsheet\Exception
126
     * @throws \RuntimeException
127
     */
128 106
    public function startSheet($index = null, array $properties = [])
129
    {
130 106
        $this->sheetWrapper->start($index, $properties);
131 106
    }
132
133
    /**
134
     * @throws \LogicException
135
     * @throws \Exception
136
     */
137 98
    public function endSheet()
138
    {
139 98
        $this->sheetWrapper->end();
140 98
    }
141
142
    /**
143
     * @param int|null $index
144
     *
145
     * @throws \LogicException
146
     */
147 83
    public function startRow(int $index = null)
148
    {
149 83
        $this->rowWrapper->start($index);
150 83
    }
151
152
    /**
153
     * @throws \LogicException
154
     */
155 79
    public function endRow()
156
    {
157 79
        $this->rowWrapper->end();
158 79
    }
159
160
    /**
161
     * @param int|null   $index
162
     * @param array      $properties
163
     *
164
     * @throws \InvalidArgumentException
165
     * @throws \LogicException
166
     * @throws \RuntimeException
167
     */
168 79
    public function startCell(int $index = null, array $properties = [])
169
    {
170 79
        $this->cellWrapper->start($index, $properties);
171 79
    }
172
173
    /**
174
     * @param null|mixed $value
175
     *
176
     * @throws \PhpOffice\PhpSpreadsheet\Exception
177
     */
178 79
    public function setCellValue($value = null)
179
    {
180 79
        $this->cellWrapper->value($value);
181 79
    }
182
183 79
    public function endCell()
184
    {
185 79
        $this->cellWrapper->end();
186 79
    }
187
188
    /**
189
     * @param string      $baseType
190
     * @param string|null $type
191
     * @param array       $properties
192
     *
193
     * @throws \LogicException
194
     * @throws \RuntimeException
195
     * @throws \InvalidArgumentException
196
     */
197 5
    public function startHeaderFooter(string $baseType, string $type = null, array $properties = [])
198
    {
199 5
        $this->headerFooterWrapper->start($baseType, $type, $properties);
200 5
    }
201
202
    /**
203
     * @throws \LogicException
204
     * @throws \InvalidArgumentException
205
     */
206 5
    public function endHeaderFooter()
207
    {
208 5
        $this->headerFooterWrapper->end();
209 5
    }
210
211
    /**
212
     * @param null|string $type
213
     * @param array       $properties
214
     *
215
     * @throws \InvalidArgumentException
216
     * @throws \LogicException
217
     */
218 5
    public function startAlignment(string $type = null, array $properties = [])
219
    {
220 5
        $this->headerFooterWrapper->startAlignment($type, $properties);
221 5
    }
222
223
    /**
224
     * @param null|string $value
225
     *
226
     * @throws \InvalidArgumentException
227
     * @throws \LogicException
228
     */
229 5
    public function endAlignment(string $value = null)
230
    {
231 5
        $this->headerFooterWrapper->endAlignment($value);
232 5
    }
233
234
    /**
235
     * @param string $path
236
     * @param array $properties
237
     *
238
     * @throws \Symfony\Component\Filesystem\Exception\IOException
239
     * @throws \InvalidArgumentException
240
     * @throws \LogicException
241
     * @throws \RuntimeException
242
     * @throws \PhpOffice\PhpSpreadsheet\Exception
243
     */
244 6
    public function startDrawing(string $path, array $properties = [])
245
    {
246 6
        $this->drawingWrapper->start($path, $properties);
247 6
    }
248
249 6
    public function endDrawing()
250
    {
251 6
        $this->drawingWrapper->end();
252 6
    }
253
}
254