Path   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 35
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setDocumentRoot() 0 4 1
A getPathToSystemRoot() 0 3 1
A setPathToSystemRoot() 0 4 1
A getDocumentRoot() 0 3 1
1
<?php
2
3
namespace kalanis\kw_paths;
4
5
6
/**
7
 * Class Path
8
 * @package kalanis\kw_paths
9
 * Parsed path data
10
 * Notes:
11
 * On web:
12
 * - documentRoot is usually container for value _SERVER['DOCUMENT_ROOT'] - path to the scripts
13
 * - staticalPath and virtualPrefix are changeable with documentRoot when the content is sent outside
14
 * - with all these values and constants inside the interface it's possible to make walk through the file tree
15
 * In admin:
16
 * - documentRoot is still basic dir from _SERVER
17
 * - pathToSystemRoot is then transfer from system root to dir where the user dir is stored
18
 * - user is name of logged user from some source
19
 * - path is path to currently processed content; depends on module if it's file or dir
20
 *
21
 * On Windows following variables contains backslashes as directory separators:
22
 * - path
23
 * - documentRoot
24
 * - pathToSystemRoot
25
 */
26
class Path
27
{
28
    protected string $documentRoot = ''; // document root as set from server
29
    protected string $pathToSystemRoot = ''; // because document root could not be every time that dir in which are user data dir
30
31
    /**
32
     * @param string $documentRoot
33
     * @throws PathsException
34
     * @return $this
35
     */
36 2
    public function setDocumentRoot(string $documentRoot): self
37
    {
38 2
        $this->documentRoot = Stuff::arrayToPath(Stuff::linkToArray($documentRoot));
39 2
        return $this;
40
    }
41
42 1
    public function getDocumentRoot(): string
43
    {
44 1
        return $this->documentRoot;
45
    }
46
47
    /**
48
     * @param string $pathToSystemRoot
49
     * @throws PathsException
50
     * @return $this
51
     */
52 2
    public function setPathToSystemRoot(string $pathToSystemRoot): self
53
    {
54 2
        $this->pathToSystemRoot = Stuff::arrayToPath(Stuff::linkToArray($pathToSystemRoot));
55 2
        return $this;
56
    }
57
58 1
    public function getPathToSystemRoot(): string
59
    {
60 1
        return $this->pathToSystemRoot;
61
    }
62
}
63