1 | <?php |
||
14 | class FlysystemEngine implements EngineInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var string Name of source file |
||
18 | */ |
||
19 | private $fname; |
||
20 | |||
21 | /** |
||
22 | * @var FilesystemInterface Filesystem where source is found |
||
23 | */ |
||
24 | private $fsystem; |
||
25 | |||
26 | /** |
||
27 | * @var DecoderInterface Decoder used to encode and deconde content |
||
28 | */ |
||
29 | private $decoder; |
||
30 | |||
31 | /** |
||
32 | * @var array Loaded documents |
||
33 | */ |
||
34 | private $docs; |
||
35 | |||
36 | /** |
||
37 | * @var string Hash of source at last reset |
||
38 | */ |
||
39 | private $hash; |
||
40 | |||
41 | /** |
||
42 | * @var bool Flag if there are un-commited changes |
||
43 | */ |
||
44 | private $inTransaction; |
||
45 | |||
46 | /** |
||
47 | * @throws FileNotFoundException If fname does not exist in filesystem |
||
48 | */ |
||
49 | public function __construct(string $fname, FilesystemInterface $fsystem, DecoderInterface $decoder = null) |
||
60 | |||
61 | public function getId(): string |
||
65 | |||
66 | public function reset() |
||
73 | |||
74 | public function getIterator(): \Generator |
||
80 | |||
81 | public function has(string $id): bool |
||
85 | |||
86 | public function read(string $id): array |
||
94 | |||
95 | public function write(string $id, array $doc): string |
||
109 | |||
110 | public function delete(string $id): bool |
||
121 | |||
122 | public function clear() |
||
129 | |||
130 | public function inTransaction(): bool |
||
134 | |||
135 | /** |
||
136 | * @throws FileModifiedException If source is out of date |
||
137 | */ |
||
138 | public function commit() |
||
149 | |||
150 | /** |
||
151 | * Create a decoder based of source file mime-type |
||
152 | */ |
||
153 | private function guessDecoder(): DecoderInterface |
||
164 | } |
||
165 |