1 | <?php |
||
41 | class FDirectory extends FSObject |
||
42 | { |
||
43 | /** |
||
44 | * @var \Closure |
||
45 | */ |
||
46 | protected $contents_lazy; |
||
47 | |||
48 | /** |
||
49 | * @var mixed |
||
50 | */ |
||
51 | protected $contents = null; |
||
52 | |||
53 | /** |
||
54 | * As we need the metadata from FSObject, we need one of those. The |
||
55 | * FDirectory a also has contents. |
||
56 | * |
||
57 | * Actually the second param should have a type like any, as we expect |
||
58 | * a list from things of the same type. |
||
59 | */ |
||
60 | 45 | public function __construct(FSObject $fs_object, \Closure $contents_lazy) |
|
65 | |||
66 | /** |
||
67 | * As this is as functor, we could map over it. |
||
68 | * |
||
69 | * Turns an FDirectory a to an FDirectory b by using the provided $trans |
||
70 | * function. |
||
71 | * |
||
72 | * @param \Closure $trans a -> b |
||
73 | */ |
||
74 | 29 | public function fmap(\Closure $trans) : FDirectory |
|
80 | |||
81 | /** |
||
82 | * We could also map the complete array to a new array, e.g. to |
||
83 | * filter it, make it longer or shorter. |
||
84 | * |
||
85 | * @param \Closure $trans [a] -> [b] |
||
86 | * @throws UnexpectedValueException in case $trans returns no error |
||
87 | */ |
||
88 | 30 | public function outer_fmap(\Closure $trans) : FDirectory |
|
94 | |||
95 | /** |
||
96 | * Define the function to be iterated with and close this level |
||
97 | * of iteration. |
||
98 | * |
||
99 | * @param \Closure $iteration a -> File|Directory -> a |
||
100 | */ |
||
101 | 18 | public function fold($start_value, $iteration) : FDirectory |
|
111 | |||
112 | /** |
||
113 | * We could filter the FDirectory by a $predicate- |
||
114 | * |
||
115 | * @param \Closure $predicate a -> bool |
||
116 | */ |
||
117 | 21 | public function filter(\Closure $predicate) : FDirectory |
|
124 | |||
125 | /** |
||
126 | * The contents of this directory. |
||
127 | * |
||
128 | * It should really return type any[], as we do want to return an array |
||
129 | * from things of the same type (but depend on the construction of this |
||
130 | * object). |
||
131 | * |
||
132 | * @return mixed[] for an FDirectory a |
||
133 | */ |
||
134 | 44 | public function fcontents() : array |
|
142 | |||
143 | /** |
||
144 | * @inheritdoc |
||
145 | */ |
||
146 | 20 | public function isFile() : bool |
|
150 | } |
||
151 |