FileInfo   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
lcom 2
cbo 0
dl 0
loc 77
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getPath() 0 3 1
A getName() 0 3 1
A getSize() 0 3 1
A getMTime() 0 3 1
A isDirectory() 0 3 1
A isReadOnly() 0 3 1
A isHidden() 0 3 1
A isSystem() 0 3 1
A isArchived() 0 3 1
A getAcls() 0 3 1
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
	/** @var string */
15
	protected $path;
16
	/** @var string */
17
	protected $name;
18
	/** @var int */
19
	protected $size;
20
	/** @var int */
21
	protected $time;
22
	/** @var int */
23
	protected $mode;
24
	/** @var callable(): ACL[] */
25
	protected $aclCallback;
26
27
	/**
28
	 * @param string $path
29
	 * @param string $name
30
	 * @param int $size
31
	 * @param int $time
32
	 * @param int $mode
33
	 * @param callable(): ACL[] $aclCallback
34
	 */
35
	public function __construct(string $path, string $name, int $size, int $time, int $mode, callable $aclCallback) {
36
		$this->path = $path;
37
		$this->name = $name;
38
		$this->size = $size;
39
		$this->time = $time;
40
		$this->mode = $mode;
41
		$this->aclCallback = $aclCallback;
42
	}
43
44
	/**
45
	 * @return string
46
	 */
47
	public function getPath(): string {
48
		return $this->path;
49
	}
50
51
	public function getName(): string {
52 200
		return $this->name;
53 200
	}
54 200
55 200
	public function getSize(): int {
56 200
		return $this->size;
57 200
	}
58 200
59 200
	public function getMTime(): int {
60
		return $this->time;
61
	}
62
63
	public function isDirectory(): bool {
64 192
		return (bool)($this->mode & IFileInfo::MODE_DIRECTORY);
65 192
	}
66
67
	public function isReadOnly(): bool {
68
		return (bool)($this->mode & IFileInfo::MODE_READONLY);
69
	}
70
71 98
	public function isHidden(): bool {
72 98
		return (bool)($this->mode & IFileInfo::MODE_HIDDEN);
73
	}
74
75
	public function isSystem(): bool {
76
		return (bool)($this->mode & IFileInfo::MODE_SYSTEM);
77
	}
78 58
79 58
	public function isArchived(): bool {
80
		return (bool)($this->mode & IFileInfo::MODE_ARCHIVE);
81
	}
82
83
	/**
84
	 * @return ACL[]
85 2
	 */
86 2
	public function getAcls(): array {
87
		return ($this->aclCallback)();
88
	}
89
}
90