Completed
Pull Request — master (#6)
by Anton
03:55
created

Container   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 47
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A breadcrumbs() 0 13 3
A path() 0 4 1
A pathFull() 0 4 1
1
<?php
2
3
namespace Modules\Filemanager\Utils {
4
5
	use Explorer;
6
7
	class Container {
8
9
		private $scheme = [], $path = '', $path_full = DIR_UPLOADS;
10
11
		# Constructor
12
13
		public function __construct(string $path = '') {
14
15
			$scheme = array_diff(preg_split('/[\/\\\\]+/', $path, -1, PREG_SPLIT_NO_EMPTY), ['.', '..']);
16
17
			$path = implode('/', $scheme); $path_full = (DIR_UPLOADS . (('' !== $path) ? ($path . '/') : ''));
18
19
			if (!Explorer::isDir($path_full)) return;
20
21
			$this->scheme = $scheme; $this->path = $path; $this->path_full = $path_full;
22
		}
23
24
		# Get breadcrumbs
25
26
		public function breadcrumbs() {
27
28
			$scheme = []; $breadcrumbs = [];
29
30
			if ([] !== $this->scheme) foreach ($this->scheme as $name) {
31
32
				$scheme[] = $name; $breadcrumbs[] = ['path' => implode('/', $scheme), 'name' => $name];
33
			}
34
35
			# ------------------------
36
37
			return $breadcrumbs;
38
		}
39
40
		# Return path
41
42
		public function path() {
43
44
			return $this->path;
45
		}
46
47
		# Return full path
48
49
		public function pathFull() {
50
51
			return $this->path_full;
52
		}
53
	}
54
}
55