1 | <?php |
||
8 | class TextFile extends AbstractFile implements TraversableFileInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var ArrayObjectLine |
||
12 | */ |
||
13 | private $lines; |
||
14 | |||
15 | /** |
||
16 | * @inheritDoc |
||
17 | */ |
||
18 | 2 | public function __construct($path, $content = '') |
|
23 | |||
24 | private function readLines() |
||
25 | { |
||
26 | 3 | $this->lines = new ArrayObjectLine(array_map(function ($line) { |
|
27 | 3 | return new Line($line); |
|
28 | 3 | }, explode(PHP_EOL, parent::getRawContent()))); |
|
29 | 3 | } |
|
30 | |||
31 | /** |
||
32 | * @return string |
||
33 | */ |
||
34 | 2 | public function getRawContent(): string |
|
38 | |||
39 | /** |
||
40 | * @param string $content |
||
41 | */ |
||
42 | 2 | public function setRawContent(string $content) |
|
47 | |||
48 | /** |
||
49 | * @return \ArrayIterator |
||
50 | */ |
||
51 | 1 | public function getIterator() |
|
55 | |||
56 | /** |
||
57 | * @param mixed $offset |
||
58 | * @return bool |
||
59 | */ |
||
60 | 2 | public function offsetExists($offset) |
|
64 | |||
65 | /** |
||
66 | * @param mixed $offset |
||
67 | * @return mixed |
||
68 | */ |
||
69 | 1 | public function offsetGet($offset) |
|
73 | |||
74 | /** |
||
75 | * @param mixed $offset |
||
76 | * @param mixed $value |
||
77 | */ |
||
78 | 1 | public function offsetSet($offset, $value) |
|
82 | |||
83 | /** |
||
84 | * @param mixed $offset |
||
85 | */ |
||
86 | 1 | public function offsetUnset($offset) |
|
90 | |||
91 | /** |
||
92 | * @return int |
||
93 | */ |
||
94 | 1 | public function count() |
|
98 | |||
99 | /** |
||
100 | * @inheritDoc |
||
101 | */ |
||
102 | 1 | public function __toString() |
|
106 | } |
||
107 |