Spine::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpEpub;
6
7
use SimpleXMLElement;
8
9
class Spine
10
{
11
    /**
12
     * @var array<int, string>
13
     */
14
    protected array $spine = [];
15
16
    /**
17
     * Spine constructor.
18
     */
19 21
    public function __construct(private readonly SimpleXMLElement $opfXml)
20
    {
21 21
        foreach ($this->opfXml->spine->itemref as $item) {
22 21
            $attr = $item->attributes();
23 21
            $this->spine[] = (string) $attr->idref;
24
        }
25
    }
26
27
    /**
28
     * @return array<int, string>
29
     */
30 7
    public function get(): array
31
    {
32 7
        return $this->spine;
33
    }
34
}
35