1 | <?php |
||
8 | class NestedRepository extends Repository |
||
9 | { |
||
10 | const SEPERATOR = '/'; |
||
11 | |||
12 | /** |
||
13 | * @inherit |
||
14 | */ |
||
15 | 4 | public function __construct($name, Config $config) |
|
21 | |||
22 | /** |
||
23 | * Get the filesystem path for a document based on it's ID. |
||
24 | * |
||
25 | * @param string $id The ID of the document. |
||
26 | * |
||
27 | * @return string The full filesystem path of the document. |
||
28 | */ |
||
29 | 3 | public function getPathForDocument($id) |
|
43 | |||
44 | /** |
||
45 | * @inherit |
||
46 | */ |
||
47 | 2 | public function delete($id) |
|
68 | |||
69 | /** |
||
70 | * @inherit |
||
71 | */ |
||
72 | 1 | protected function write($path, $contents) |
|
81 | |||
82 | /** |
||
83 | * Gets just the filename for a document based on it's ID. |
||
84 | * |
||
85 | * @param string $id The ID of the document. |
||
86 | * |
||
87 | * @return string The filename of the document, including extension. |
||
88 | */ |
||
89 | 3 | public function getFilename($id) |
|
93 | |||
94 | /** |
||
95 | * Get an array containing the path of all files in this repository |
||
96 | * |
||
97 | * @return array An array, item is a file path. |
||
98 | */ |
||
99 | 1 | public function getAllFiles() |
|
107 | |||
108 | 3 | protected function isNestedId($id) |
|
112 | |||
113 | /** |
||
114 | * Checks to see if a document ID is valid |
||
115 | * |
||
116 | * @param string $id The ID to check |
||
117 | * |
||
118 | * @return bool True if valid, otherwise false |
||
119 | */ |
||
120 | 3 | protected function validateId($id) |
|
126 | |||
127 | 1 | protected function getFilesRecursive($dir, array &$result, $ext) |
|
150 | |||
151 | /** |
||
152 | * @inherit |
||
153 | */ |
||
154 | 1 | protected function getIdFromPath($path, $ext) |
|
158 | |||
159 | } |
||
160 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: