1 | <?php |
||
13 | class FlysystemEngine implements EngineInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var string Name of source file |
||
17 | */ |
||
18 | private $fname; |
||
19 | |||
20 | /** |
||
21 | * @var FilesystemInterface Filesystem where source is found |
||
22 | */ |
||
23 | private $fs; |
||
24 | |||
25 | /** |
||
26 | * @var DecoderInterface Decoder used to encode and deconde content |
||
27 | */ |
||
28 | private $decoder; |
||
29 | |||
30 | /** |
||
31 | * @var array Loaded documents |
||
32 | */ |
||
33 | private $docs; |
||
34 | |||
35 | /** |
||
36 | * @var string Hash of source at last reset |
||
37 | */ |
||
38 | private $hash; |
||
39 | |||
40 | /** |
||
41 | * @var bool Flag if there are un-commited changes |
||
42 | */ |
||
43 | private $inTransaction; |
||
44 | |||
45 | public function __construct(string $fname, FilesystemInterface $fs, DecoderInterface $decoder = null) |
||
52 | |||
53 | public function getId(): string |
||
57 | |||
58 | public function reset() |
||
65 | |||
66 | public function getIterator(): \Generator |
||
72 | |||
73 | public function has(string $id): bool |
||
77 | |||
78 | public function read(string $id): array |
||
86 | |||
87 | public function write(string $id, array $doc): string |
||
101 | |||
102 | public function delete(string $id): bool |
||
113 | |||
114 | public function clear() |
||
121 | |||
122 | public function inTransaction(): bool |
||
126 | |||
127 | /** |
||
128 | * @throws SourceModifiedException If source is out of date |
||
129 | */ |
||
130 | public function commit() |
||
141 | |||
142 | /** |
||
143 | * Create a decoder based of source file mime-type |
||
144 | */ |
||
145 | private function guessDecoder(): DecoderInterface |
||
156 | } |
||
157 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.