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

DriverAbstract   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 2
dl 0
loc 62
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
call() 0 1 ?
B handleStat() 0 11 6
A handleChmod() 0 8 3
A handleChown() 0 8 3
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