Validations::setError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace WSW\SimpleUpload\Traits\Upload;
4
5
use League\Flysystem\Adapter\Local;
6
7
/**
8
 * Trait Validations
9
 * @package WSW\SimpleUpload\Traits\Upload
10
 */
11
trait Validations
12
{
13
    /**
14
     * @var int
15
     */
16
    private $error;
17
18
    /**
19
     * @return int
20
     */
21 3
    public function getError()
22
    {
23 3
        return $this->error;
24
    }
25
26
    /**
27
     * @param int $error
28
     * @return self
29
     */
30 3
    public function setError($error)
31
    {
32 3
        $this->error = $error;
33 3
        return $this;
34
    }
35
36
    /**
37
     * @param string $ext
38
     * @param array $list
39
     * @return bool
40
     */
41 4
    private function extensionIsValid($ext, array $list)
42
    {
43 4
        if (empty($list)) {
44 1
            return true;
45
        }
46
47 3
        return (bool) in_array($ext, $list);
48
    }
49
50
    /**
51
     * @return bool
52
     */
53 3
    private function uploadWithError()
54
    {
55 3
        return (bool) $this->getError();
56
    }
57
}
58