Completed
Push — master ( e2fb6c...c5285b )
by Dmitry
02:55
created

Context::getPerson()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace Basis;
4
5
use Carbon\Carbon;
6
7
class Context
8
{
9
    public $access;
10
    public $channel;
11
    public $session;
12
13
    public $company;
14
    public $person;
15
    public $module;
16
17
    public $parent;
18
    public $event;
19
20 1
    public function reset($context = []) : self
21
    {
22 1
        foreach ($this as $k => $_) {
0 ignored issues
show
Bug introduced by
The expression $this of type this<Basis\Context> is not traversable.
Loading history...
23 1
            $this->$k = null;
24
        }
25 1
        $this->apply($context);
26
27 1
        return $this;
28
    }
29
30 1
    public function apply($data) : self
31
    {
32 1
        foreach ($data as $k => $v) {
33 1
            $this->$k = $v;
34
        }
35
36 1
        return $this;
37
    }
38
39
    public function getPerson()
40
    {
41
        return $this->parent ? $this->parent->person : $this->person;
42
    }
43
}
44