1 | <?php |
||
28 | class SearchFolderService extends FilesService { |
||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $virtualRootLevel = null; |
||
33 | |||
34 | /** |
||
35 | * This returns what we think is the current folder node based on a given path |
||
36 | * |
||
37 | * @param string $location |
||
38 | * @param string[] $features |
||
39 | * |
||
40 | * @return array <string,Folder,bool> |
||
41 | */ |
||
42 | 6 | public function getCurrentFolder($location, $features) { |
|
43 | 6 | $this->features = $features; |
|
44 | |||
45 | 6 | return $this->findFolder($location); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * This returns the current folder node based on a path |
||
50 | * |
||
51 | * If the path leads to a file, we'll return the node of the containing folder |
||
52 | * |
||
53 | * If we can't find anything, we try with the parent folder, up to the root or until we reach |
||
54 | * our recursive limit |
||
55 | * |
||
56 | * @param string $location |
||
57 | * @param int $depth |
||
58 | * |
||
59 | * @return array <string,Folder,bool> |
||
60 | */ |
||
61 | 7 | private function findFolder($location, $depth = 0) { |
|
80 | |||
81 | /** |
||
82 | * Makes sure we don't go too far up before giving up |
||
83 | * |
||
84 | * @param string $location |
||
85 | * @param int $depth |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 9 | private function validateLocation($location, $depth) { |
|
90 | 9 | if ($depth === 4) { |
|
91 | // We can't find anything, so we decide to return data for the root folder |
||
92 | 1 | $location = ''; |
|
93 | } |
||
94 | |||
95 | 9 | return $location; |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * Makes sure that the folder is not empty, does meet our requirements in terms of location and |
||
100 | * returns details about it |
||
101 | * |
||
102 | * @param string $path |
||
103 | * @param Folder $node |
||
104 | * |
||
105 | * @return array <string,Folder,bool> |
||
|
|||
106 | * @throws ForbiddenServiceException|NotFoundServiceException |
||
107 | */ |
||
108 | 12 | private function sendFolder($path, $node) { |
|
120 | |||
121 | } |
||
122 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.