AbstractXMLDictionary   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 11 4
1
<?php declare(strict_types = 1);
2
3
namespace Spaghetti\XLSXParser;
4
5
use function implode;
6
use function is_array;
7
use function trim;
8
9
/**
10
 * @internal
11
 */
12
abstract class AbstractXMLDictionary extends AbstractXMLResource
13
{
14
    protected bool $valid = true;
15
    protected array $values = [];
16
17
    public function get(int $index): mixed
18
    {
19
        while ($this->valid && !isset($this->values[$index])) {
20
            $this->readNext();
21
        }
22
23
        if (is_array(value: $this->values[$index])) {
24
            return trim(string: implode(separator: ' ', array: $this->values[$index]));
25
        }
26
27
        return $this->values[$index];
28
    }
29
30
    abstract protected function readNext();
31
}
32