Passed
Push — master ( c25309...927e33 )
by Robin
04:02 queued 29s
created

FileInfo::isDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2014 Robin Appelman <[email protected]>
4
 * This file is licensed under the Licensed under the MIT license:
5
 * http://opensource.org/licenses/MIT
6
 */
7
8
namespace Icewind\SMB\Wrapped;
9
10
use Icewind\SMB\ACL;
11
use Icewind\SMB\IFileInfo;
12
13
class FileInfo implements IFileInfo {
14
	/**
15
	 * @var string
16
	 */
17
	protected $path;
18
19
	/**
20
	 * @var string
21
	 */
22
	protected $name;
23
24
	/**
25
	 * @var int
26
	 */
27
	protected $size;
28
29
	/**
30
	 * @var int
31
	 */
32
	protected $time;
33
34
	/**
35
	 * @var int
36
	 */
37
	protected $mode;
38
39
	/**
40
	 * @var callable
41
	 */
42
	protected $aclCallback;
43
44
	/**
45
	 * @param string $path
46
	 * @param string $name
47
	 * @param int $size
48
	 * @param int $time
49
	 * @param int $mode
50
	 * @param callable $aclCallback
51
	 */
52 200
	public function __construct($path, $name, $size, $time, $mode, callable $aclCallback) {
53 200
		$this->path = $path;
54 200
		$this->name = $name;
55 200
		$this->size = $size;
56 200
		$this->time = $time;
57 200
		$this->mode = $mode;
58 200
		$this->aclCallback = $aclCallback;
59 200
	}
60
61
	/**
62
	 * @return string
63
	 */
64 192
	public function getPath() {
65 192
		return $this->path;
66
	}
67
68
	/**
69
	 * @return string
70
	 */
71 98
	public function getName() {
72 98
		return $this->name;
73
	}
74
75
	/**
76
	 * @return int
77
	 */
78 58
	public function getSize() {
79 58
		return $this->size;
80
	}
81
82
	/**
83
	 * @return int
84
	 */
85 2
	public function getMTime() {
86 2
		return $this->time;
87
	}
88
89
	/**
90
	 * @return bool
91
	 */
92 174
	public function isDirectory() {
93 174
		return (bool)($this->mode & IFileInfo::MODE_DIRECTORY);
94
	}
95
96
	/**
97
	 * @return bool
98
	 */
99 2
	public function isReadOnly() {
100 2
		return (bool)($this->mode & IFileInfo::MODE_READONLY);
101
	}
102
103
	/**
104
	 * @return bool
105
	 */
106 12
	public function isHidden() {
107 12
		return (bool)($this->mode & IFileInfo::MODE_HIDDEN);
108
	}
109
110
	/**
111
	 * @return bool
112
	 */
113
	public function isSystem() {
114
		return (bool)($this->mode & IFileInfo::MODE_SYSTEM);
115
	}
116
117
	/**
118
	 * @return bool
119
	 */
120
	public function isArchived() {
121
		return (bool)($this->mode & IFileInfo::MODE_ARCHIVE);
122
	}
123
124
	/**
125
	 * @return ACL[]
126
	 */
127
	public function getAcls(): array {
128
		return ($this->aclCallback)();
129
	}
130
}
131