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

Behavior   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBehavior() 0 6 1
A hasBehavior() 0 6 1
A setBehavior() 0 6 1
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