Completed
Push — master ( 97f3ba...baa78e )
by Kamil
03:56
created

DriverAbstract::handleChmod()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 2
nop 1
crap 12
1
<?php
2
3
namespace Dazzle\Filesystem\Driver;
4
5
use Dazzle\Loop\LoopAwareTrait;
6
use Dazzle\Promise\PromiseInterface;
7
use Dazzle\Throwable\Exception\Runtime\ReadException;
8
use DateTimeImmutable;
9
10
abstract class DriverAbstract
11
{
12
    use LoopAwareTrait;
13
14
    /**
15
     * @var array
16
     */
17
    protected $options;
18
19
    /**
20
     * @internal
21
     * @param string $func
22
     * @param array $args
23
     * @return PromiseInterface
24
     */
25
    abstract public function call($func, $args = []);
26
27
    /**
28
     * Handle stat command.
29
     *
30
     * @internal
31
     */
32
    public function handleStat($info)
33
    {
34
        if (!$info && $this->options['output.control'])
35
        {
36
            throw new ReadException('Function stat() failed on given node!');
37
        }
38
        $info['atime'] && $info['atime'] = new DateTimeImmutable('@' . $info['atime']);
39
        $info['mtime'] && $info['mtime'] = new DateTimeImmutable('@' . $info['mtime']);
40
        $info['ctime'] && $info['ctime'] = new DateTimeImmutable('@' . $info['ctime']);
41
        return $info;
42
    }
43
44
    /**
45
     * Handle stat command.
46
     *
47
     * @internal
48
     */
49
    public function handleChmod($info)
50
    {
51
        if (!$info && $this->options['output.control'])
52
        {
53
            throw new ReadException('Function chmod() failed on given node!');
54
        }
55
        return $info;
56
    }
57
58
    /**
59
     * Handle stat command.
60
     *
61
     * @internal
62
     */
63
    public function handleChown($stat)
64
    {
65
        if (!$stat && $this->options['output.control'])
66
        {
67
            throw new ReadException('Function stat() failed on given node!');
68
        }
69
        return $stat;
70
    }
71
}
72