1 | <?php |
||
21 | class RenderIndexFileStream implements FileStream |
||
22 | { |
||
23 | /** |
||
24 | * @var SitemapIndexRender |
||
25 | */ |
||
26 | private $render; |
||
27 | |||
28 | /** |
||
29 | * @var FileStream |
||
30 | */ |
||
31 | private $substream; |
||
32 | |||
33 | /** |
||
34 | * @var StreamState |
||
35 | */ |
||
36 | private $state; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $filename = ''; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | private $index = 0; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | private $buffer = ''; |
||
52 | |||
53 | /** |
||
54 | * @param SitemapIndexRender $render |
||
55 | * @param FileStream $substream |
||
56 | * @param string $filename |
||
57 | */ |
||
58 | 10 | public function __construct(SitemapIndexRender $render, FileStream $substream, string $filename) |
|
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | 1 | public function getFilename(): string |
|
73 | |||
74 | 7 | public function open(): void |
|
80 | |||
81 | 8 | public function close(): void |
|
89 | |||
90 | /** |
||
91 | * @param Url $url |
||
92 | */ |
||
93 | 4 | public function push(Url $url): void |
|
106 | |||
107 | 7 | private function addSubStreamFileToIndex(): void |
|
127 | |||
128 | /** |
||
129 | * @param string $filename |
||
130 | * @param int $index |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | 7 | private function getIndexPartFilename(string $filename, int $index): string |
|
144 | } |
||
145 |
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
.