Path   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 63
ccs 17
cts 17
cp 1
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdapter() 0 4 1
A setAdapter() 0 5 1
A setPathLocal() 0 8 2
A setPath() 0 10 2
A getPath() 0 4 1
1
<?php
2
3
namespace WSW\SimpleUpload\Traits\Upload;
4
5
use League\Flysystem\Adapter\Local;
6
use League\Flysystem\AdapterInterface;
7
8
trait Path
9
{
10
    /**
11
     * @var AdapterInterface
12
     */
13
    private $adapter;
14
15
    /**
16
     * @return AdapterInterface
17
     */
18 3
    public function getAdapter()
19
    {
20 3
        return $this->adapter;
21
    }
22
23
    /**
24
     * @param AdapterInterface $adapter
25
     * @return self
26
     */
27 3
    public function setAdapter(AdapterInterface $adapter)
28
    {
29 3
        $this->adapter = $adapter;
30 3
        return $this;
31
    }
32
33
34
    /**
35
     * @param string $base
36
     * @param string $dir
37
     * @return string
38
     */
39 3
    public function setPathLocal($base, $dir)
40
    {
41 3
        if (DIRECTORY_SEPARATOR === $dir{0}) {
42 2
            return $dir;
43
        }
44
45 1
        return $base . ltrim($dir, DIRECTORY_SEPARATOR);
46
    }
47
48
    /**
49
     * @param string $path
50
     * @return self
51
     */
52 1
    public function setPath($path)
53
    {
54 1
        if ($this->getAdapter() instanceof Local) {
55 1
            $base = $this->getAdapter()->getPathPrefix();
56 1
            $path = $this->setPathLocal($base, $path);
57
        }
58
59 1
        $this->getAdapter()->setPathPrefix($path);
60 1
        return $this;
61
    }
62
63
    /**
64
     * @return string
65
     */
66 3
    public function getPath()
67
    {
68 3
        return $this->getAdapter()->getPathPrefix();
69
    }
70
}
71