Completed
Push — master ( a34372...4a8cdc )
by KwangSeob
01:46
created

VisibilityTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A setVisibility() 0 17 4
1
<?php
2
3
namespace JiraRestApi\Issue;
4
5
trait VisibilityTrait {
6
7
    /**
8
     *
9
     * @param Visibility $type
10
     * @param null       $value
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $value is correct as it would always require null to be passed?
Loading history...
11
     *
12
     * @return $this
13
     */
14
    public function setVisibility($type, $value = null)
15
    {
16
        if (is_null($this->visibility)) {
17
            $this->visibility = new Visibility();
0 ignored issues
show
Bug Best Practice introduced by
The property visibility does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
18
        }
19
20
        if (is_array($type)) {
0 ignored issues
show
introduced by
The condition is_array($type) is always false.
Loading history...
21
            $this->visibility->setType($type['type']);
22
            $this->visibility->setValue($type['value']);
23
        } elseif ($type instanceof Visibility) {
0 ignored issues
show
introduced by
$type is always a sub-type of JiraRestApi\Issue\Visibility.
Loading history...
24
            $this->visibility = $type;
25
        } else {
26
            $this->visibility->setType($type);
27
            $this->visibility->setValue($value);
28
        }
29
30
        return $this;
31
    }
32
}