TemporaryNode::getPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of peridot-temporary-plugin.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace holyshared\peridot\temporary;
13
14
15
abstract class TemporaryNode implements FileSystemNode
16
{
17
18
    protected $node;
19
20
21
    public function getName()
22
    {
23
        return $this->node->getFilename();
24
    }
25
26
    public function getPath()
27
    {
28
        return $this->node->getPathname();
29
    }
30
31
    public function exists()
32
    {
33
        return file_exists($this->getPath());
34
    }
35
36
    public function remove()
37
    {
38
        if ($this->exists() === false) {
39
            return;
40
        }
41
        $this->removeNode();
42
    }
43
44
    public function chmod($mode)
45
    {
46
        chmod($this->getPath(), $mode);
47
    }
48
49
    public function getPermission()
50
    {
51
        $value = $this->node->getPerms();
52
        $value = substr(sprintf('%o', $value), -4); //Example: 100444
53
54
        return intval($value, 8);
55
    }
56
57
    public function isReadable()
58
    {
59
        return $this->node->isReadable();
60
    }
61
62
    public function isWritable()
63
    {
64
        return $this->node->isWritable();
65
    }
66
67
    public function __destruct()
68
    {
69
        $this->remove();
70
        $this->node = null;
71
    }
72
73
    abstract protected function removeNode();
74
75
}
76