1 | <?php |
||
30 | class Path |
||
31 | { |
||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $path; |
||
36 | |||
37 | /** |
||
38 | * Path constructor. |
||
39 | * @param string $path |
||
40 | */ |
||
41 | 4 | private function __construct($path) |
|
45 | |||
46 | /** |
||
47 | * @throws OptimiseException |
||
48 | */ |
||
49 | public function __destruct() |
||
50 | { |
||
51 | if ($this->path && is_dir($this->path) && !self::delTree($this->path)) |
||
52 | throw new OptimiseException('problems during removing of path directory'); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | 4 | public function getPath() |
|
62 | |||
63 | /** |
||
64 | * @param string $path |
||
65 | */ |
||
66 | public function setPath($path) |
||
70 | |||
71 | |||
72 | /** |
||
73 | * @throws OptimiseException on problems during creation of tmp dir |
||
74 | */ |
||
75 | 4 | static public function createPath() |
|
87 | |||
88 | /** |
||
89 | * remove a no empty dir |
||
90 | * @param $dir |
||
91 | * @return bool |
||
92 | */ |
||
93 | private static function delTree($dir) { |
||
94 | $files = array_diff(scandir($dir), array('.','..')); |
||
95 | foreach ($files as $file) { |
||
96 | (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); |
||
97 | } |
||
98 | return rmdir($dir); |
||
99 | } |
||
100 | |||
101 | |||
102 | /** |
||
103 | * @return string |
||
104 | */ |
||
105 | 4 | public function getModelPath() |
|
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | */ |
||
113 | 4 | public function getUsersPath() |
|
117 | |||
118 | /** |
||
119 | * @return string |
||
120 | */ |
||
121 | 4 | public function getMeetingsPath() |
|
125 | |||
126 | /** |
||
127 | * @return string |
||
128 | */ |
||
129 | 4 | public function getMeetingsDurationPath() |
|
133 | |||
134 | /** |
||
135 | * @return string |
||
136 | */ |
||
137 | 4 | public function getMeetingsAvailabilityPath() |
|
141 | |||
142 | /** |
||
143 | * @return string |
||
144 | */ |
||
145 | 4 | public function getUsersAvailabilityPath() |
|
149 | |||
150 | /** |
||
151 | * @return string |
||
152 | */ |
||
153 | 4 | public function getUsersMeetingsPath() |
|
157 | |||
158 | /** |
||
159 | * @return string |
||
160 | */ |
||
161 | 4 | public function getXPath() |
|
165 | |||
166 | /** |
||
167 | * @return string |
||
168 | */ |
||
169 | 4 | public function getYPath() |
|
173 | |||
174 | /** |
||
175 | * @return string |
||
176 | */ |
||
177 | 4 | public function getOutputPath() |
|
181 | } |