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

VisibilityTrait::setVisibility()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 6
nop 2
dl 0
loc 17
rs 9.9
c 0
b 0
f 0
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
}