Total Complexity | 8 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | trait FileInterface |
||
19 | { |
||
20 | /** @var Iterator|array $header */ |
||
21 | private $header = []; |
||
22 | |||
23 | /** |
||
24 | * @inheritDoc |
||
25 | */ |
||
26 | public function getHeader() |
||
27 | { |
||
28 | return !empty($this->header) ? $this->header : (function () { |
||
29 | $this->setHeader(); |
||
30 | |||
31 | return $this->header; |
||
32 | })(); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @inheritDoc |
||
37 | */ |
||
38 | private function setHeader(): ReferencedSignature |
||
39 | { |
||
40 | if ($this->hasHeader()) { |
||
41 | $this->header = $this->isContentIterator() ? (function () { |
||
42 | return $this->content->current(); |
||
43 | })() : array_shift($this->getContent()); |
||
|
|||
44 | } |
||
45 | |||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @inheritDoc |
||
51 | */ |
||
52 | public function hasHeader(): bool |
||
55 | } |
||
56 | |||
57 | private function isContentIterator() |
||
58 | { |
||
59 | return $this->content instanceof Iterator; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @inheritDoc |
||
64 | */ |
||
65 | public function getContent(): Iterator |
||
68 | } |
||
69 | } |
||
70 |