Completed
Push — master ( 576435...3e25f9 )
by Ronaldo
05:23
created

Validations   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 47
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getError() 0 4 1
A setError() 0 5 1
A extensionIsValid() 0 8 2
A uploadWithError() 0 4 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
    public function getError()
22
    {
23
        return $this->error;
24
    }
25
26
    /**
27
     * @param int $error
28
     * @return self
29
     */
30
    public function setError($error)
31
    {
32
        $this->error = $error;
33
        return $this;
34
    }
35
36
    /**
37
     * @param string $ext
38
     * @param array $list
39
     * @return bool
40
     */
41
    private function extensionIsValid($ext, array $list)
42
    {
43
        if (empty($list)) {
44
            return true;
45
        }
46
47
        return (bool) in_array($ext, $list);
48
    }
49
50
    /**
51
     * @return bool
52
     */
53
    private function uploadWithError()
54
    {
55
        return (bool) $this->getError();
56
    }
57
}
58