Test Failed
Push — master ( 4bba41...7bbbf4 )
by Julien
04:35
created

Behavior::getBehavior()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Model;
13
14
use Phalcon\Mvc\Model\BehaviorInterface;
15
use Phalcon\Mvc\ModelInterface;
16
use Zemit\Mvc\Model\AbstractTrait\AbstractModelsManager;
17
18
trait Behavior
19
{
20
    use AbstractModelsManager;
21
    
22
    public function getBehavior(string $behaviorName): BehaviorInterface
23
    {
24
        $modelsManager = $this->getModelsManager();
25
        assert($modelsManager instanceof ManagerInterface);
26
        assert($this instanceof ModelInterface);
27
        return $modelsManager->getBehavior($this, $behaviorName);
28
    }
29
    
30
    public function setBehavior(string $behaviorName, BehaviorInterface $behavior): void
31
    {
32
        $modelsManager = $this->getModelsManager();
33
        assert($modelsManager instanceof ManagerInterface);
34
        assert($this instanceof ModelInterface);
35
        $modelsManager->setBehavior($this, $behaviorName, $behavior);
36
    }
37
    
38
    public function hasBehavior(string $behaviorName): bool
39
    {
40
        $modelsManager = $this->getModelsManager();
41
        assert($modelsManager instanceof ManagerInterface);
42
        assert($this instanceof ModelInterface);
43
        return $modelsManager->hasBehavior($this, $behaviorName);
44
    }
45
}
46