HasManagerTrait::setManager()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Nip\Records\Relations\Traits;
4
5
use Nip\Records\AbstractModels\Record;
6
use Nip\Records\AbstractModels\RecordManager;
7
use Nip\Records\Traits\Relations\HasRelationsRecordsTrait;
8
9
/**
10
 * Class HasManagerTrait
11
 * @package Nip\Records\Relations\Traits
12
 *
13
 * @method Record getItem()
14
 */
15
trait HasManagerTrait
16
{
17
18
    /**
19
     * @var RecordManager
20
     */
21
    protected $manager = null;
22
23
    /**
24
     * @return RecordManager|\Nip\Records\RecordManager
25
     */
26 8
    public function getManager()
27
    {
28 8
        if ($this->manager == null) {
29 2
            $this->initManager();
30
        }
31
32 8
        return $this->manager;
33
    }
34
35
    /**
36
     * @param HasRelationsRecordsTrait $manager
37
     */
38 18
    public function setManager($manager)
39
    {
40 18
        $this->manager = $manager;
0 ignored issues
show
Documentation Bug introduced by
It seems like $manager of type Nip\Records\Traits\Relat...asRelationsRecordsTrait is incompatible with the declared type Nip\Records\AbstractModels\RecordManager of property $manager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41 18
    }
42
43
    /**
44
     * @return void
45
     */
46 2
    public function initManager()
47
    {
48 2
        $this->manager = $this->getItem()->getManager();
49 2
    }
50
51
    /**
52
     * @return bool
53
     */
54 7
    public function hasManager()
55
    {
56 7
        return $this->manager instanceof RecordManager;
57
    }
58
}
59