CanDir   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 40
dl 0
loc 87
ccs 38
cts 38
cp 1
rs 10
c 1
b 0
f 0
wmc 16

9 Methods

Rating   Name   Duplication   Size   Complexity  
A isWritable() 0 7 2
A isDir() 0 7 2
A isFile() 0 7 2
A created() 0 7 2
A exists() 0 7 2
A __construct() 0 4 1
A isReadable() 0 7 2
A size() 0 7 2
A noDirectoryDelimiterSet() 0 3 1
1
<?php
2
3
namespace kalanis\kw_files\Processing\Storage\Nodes;
4
5
6
use DateTimeInterface;
7
use kalanis\kw_files\FilesException;
8
use kalanis\kw_files\Interfaces\IFLTranslations;
9
use kalanis\kw_storage\Interfaces\IPassDirs;
10
use kalanis\kw_storage\StorageException;
11
12
13
/**
14
 * Class CanDir
15
 * @package kalanis\kw_files\Processing\Storage\Nodes
16
 * Process dirs via predefined api
17
 */
18
class CanDir extends ANodes
19
{
20
    protected IPassDirs $storage;
21
22 9
    public function __construct(IPassDirs $storage, ?IFLTranslations $lang = null)
23
    {
24 9
        $this->storage = $storage;
25 9
        $this->setFlLang($lang);
26
    }
27
28 3
    public function exists(array $entry): bool
29
    {
30 3
        $path = $this->getStorageSeparator() . $this->compactName($entry, $this->getStorageSeparator());
31
        try {
32 3
            return $this->storage->exists($path);
33 1
        } catch (StorageException $ex) {
34 1
            throw new FilesException($ex->getMessage(), $ex->getCode(), $ex);
35
        }
36
    }
37
38 1
    public function isReadable(array $entry): bool
39
    {
40 1
        $path = $this->getStorageSeparator() . $this->compactName($entry, $this->getStorageSeparator());
41
        try {
42 1
            return $this->storage->isReadable($path);
43 1
        } catch (StorageException $ex) {
44 1
            throw new FilesException($ex->getMessage(), $ex->getCode(), $ex);
45
        }
46
    }
47
48 1
    public function isWritable(array $entry): bool
49
    {
50 1
        $path = $this->getStorageSeparator() . $this->compactName($entry, $this->getStorageSeparator());
51
        try {
52 1
            return $this->storage->isWritable($path);
53 1
        } catch (StorageException $ex) {
54 1
            throw new FilesException($ex->getMessage(), $ex->getCode(), $ex);
55
        }
56
    }
57
58 3
    public function isDir(array $entry): bool
59
    {
60 3
        $path = $this->getStorageSeparator() . $this->compactName($entry, $this->getStorageSeparator());
61
        try {
62 3
            return $this->storage->isDir($path);
63 1
        } catch (StorageException $ex) {
64 1
            throw new FilesException($ex->getMessage(), $ex->getCode(), $ex);
65
        }
66
    }
67
68 3
    public function isFile(array $entry): bool
69
    {
70 3
        $path = $this->getStorageSeparator() . $this->compactName($entry, $this->getStorageSeparator());
71
        try {
72 3
            return $this->storage->isFile($path);
73 1
        } catch (StorageException $ex) {
74 1
            throw new FilesException($ex->getMessage(), $ex->getCode(), $ex);
75
        }
76
    }
77
78 3
    public function size(array $entry): ?int
79
    {
80 3
        $path = $this->getStorageSeparator() . $this->compactName($entry, $this->getStorageSeparator());
81
        try {
82 3
            return $this->storage->size($path);
83 1
        } catch (StorageException $ex) {
84 1
            throw new FilesException($ex->getMessage(), $ex->getCode(), $ex);
85
        }
86
    }
87
88 3
    public function created(array $entry): ?DateTimeInterface
89
    {
90 3
        $path = $this->getStorageSeparator() . $this->compactName($entry, $this->getStorageSeparator());
91
        try {
92 3
            return $this->storage->created($path);
93 1
        } catch (StorageException $ex) {
94 1
            throw new FilesException($ex->getMessage(), $ex->getCode(), $ex);
95
        }
96
    }
97
98
    /**
99
     * @return string
100
     * @codeCoverageIgnore only when path fails
101
     */
102
    protected function noDirectoryDelimiterSet(): string
103
    {
104
        return $this->getFlLang()->flNoDirectoryDelimiterSet();
105
    }
106
}
107