1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\kw_files\Processing\Volume; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\kw_files\FilesException; |
7
|
|
|
use kalanis\kw_files\Interfaces\IProcessNodes; |
8
|
|
|
use kalanis\kw_files\Processing\TPath; |
9
|
|
|
use kalanis\kw_files\Processing\TPathTransform; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class ProcessNode |
14
|
|
|
* @package kalanis\kw_files\Processing\Volume |
15
|
|
|
* Process nodes in basic ways |
16
|
|
|
*/ |
17
|
|
|
class ProcessNode implements IProcessNodes |
18
|
|
|
{ |
19
|
|
|
use TPath; |
20
|
|
|
use TPathTransform; |
21
|
|
|
|
22
|
1 |
|
public function __construct(string $path = '') |
23
|
|
|
{ |
24
|
1 |
|
$this->setPath($path); |
25
|
1 |
|
} |
26
|
|
|
|
27
|
1 |
|
public function exists(array $entry): bool |
28
|
|
|
{ |
29
|
1 |
|
return @file_exists($this->fullPath($entry)); |
30
|
|
|
} |
31
|
|
|
|
32
|
1 |
|
public function isReadable(array $entry): bool |
33
|
|
|
{ |
34
|
1 |
|
return @is_readable($this->fullPath($entry)); |
35
|
|
|
} |
36
|
|
|
|
37
|
1 |
|
public function isWritable(array $entry): bool |
38
|
|
|
{ |
39
|
1 |
|
return @is_writable($this->fullPath($entry)); |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
public function isDir(array $entry): bool |
43
|
|
|
{ |
44
|
1 |
|
return @is_dir($this->fullPath($entry)); |
45
|
|
|
} |
46
|
|
|
|
47
|
1 |
|
public function isFile(array $entry): bool |
48
|
|
|
{ |
49
|
1 |
|
return @is_file($this->fullPath($entry)); |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
public function size(array $entry): ?int |
53
|
|
|
{ |
54
|
1 |
|
$path = $this->fullPath($entry); |
55
|
1 |
|
$size = @filesize($path); |
56
|
1 |
|
return (false === $size) ? null : $size; |
57
|
|
|
} |
58
|
|
|
|
59
|
1 |
|
public function created(array $entry): ?int |
60
|
|
|
{ |
61
|
1 |
|
$path = $this->fullPath($entry); |
62
|
1 |
|
$created = @filemtime($path); |
63
|
1 |
|
return (false === $created) ? null : $created; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param array<string> $path |
68
|
|
|
* @throws FilesException |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
1 |
|
protected function fullPath(array $path): string |
72
|
|
|
{ |
73
|
1 |
|
return $this->getPath() . DIRECTORY_SEPARATOR . $this->compactName($path); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|