HasUploadTrait   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 9
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 76
ccs 15
cts 15
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUploadContainer() 0 6 1
A setUploadOptions() 0 6 1
A setUploadRules() 0 6 1
A getUploadContainer() 0 4 2
A getUploadOptions() 0 4 2
A getUploadRules() 0 4 2
1
<?php
2
3
namespace Sirius\Input\Traits;
4
5
use Sirius\Input\Specs;
6
7
trait HasUploadTrait
8
{
9
10
    /**
11
     * Returns the upload container for the element
12
     *
13
     * @return null|mixed
14
     */
15 1
    public function getUploadContainer()
16
    {
17 1
        return isset($this[Specs::UPLOAD_CONTAINER]) ? $this[Specs::UPLOAD_CONTAINER] : null;
18
    }
19
20
    /**
21
     * Sets the upload container for the elment
22
     *
23
     * @param string|\Sirius\Upload\Container\ContainerInterface $container
24
     *
25
     * @return $this
26
     */
27 3
    public function setUploadContainer($container)
28
    {
29 3
        $this[Specs::UPLOAD_CONTAINER] = $container;
30
31 3
        return $this;
32
    }
33
34
    /**
35
     * Get the upload options (overwrite, auto confirm, etc)
36
     *
37
     * @see \Sirius\Upload\Handler
38
     * @return null|array
39
     */
40 1
    public function getUploadOptions()
41
    {
42 1
        return isset($this[Specs::UPLOAD_OPTIONS]) ? $this[Specs::UPLOAD_OPTIONS] : null;
43
    }
44
45
    /**
46
     * Get the upload options (overwrite, auto confirm, etc)
47
     *
48
     * @param array $options
49
     *
50
     * @return $this
51
     */
52 2
    public function setUploadOptions($options = array())
53
    {
54 2
        $this[Specs::UPLOAD_OPTIONS] = $options;
55
56 2
        return $this;
57
    }
58
59
    /**
60
     * Get the validation rules for the uploaded file(s)
61
     *
62
     * @return null|array
63
     */
64 1
    public function getUploadRules()
65
    {
66 1
        return isset($this[Specs::UPLOAD_RULES]) ? $this[Specs::UPLOAD_RULES] : null;
67
    }
68
69
    /**
70
     * Sets the validation rules for the uploaded file(s)
71
     *
72
     * @param array $rules
73
     *
74
     * @return $this
75
     */
76 3
    public function setUploadRules($rules = array())
77
    {
78 3
        $this[Specs::UPLOAD_RULES] = $rules;
79
80 3
        return $this;
81
    }
82
}
83