Passed
Push — master ( 3f333d...123b10 )
by Julien
05:03
created

Action   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 12
dl 0
loc 25
ccs 9
cts 11
cp 0.8182
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A notify() 0 18 5
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\Behavior;
13
14
use Phalcon\Mvc\Model\Behavior;
15
use Phalcon\Mvc\ModelInterface;
16
17
class Action extends Behavior
18
{
19
    use SkippableTrait;
20
    
21
    /**
22
     * @return void
23
     */
24 2
    public function notify(string $type, ModelInterface $model)
25
    {
26 2
        if (!$this->isEnabled()) {
27
            return;
28
        }
29
        
30 2
        if (!$this->mustTakeAction($type)) {
31 2
            return;
32
        }
33
34 2
        $options = $this->getOptions($type);
35 2
        if (empty($options)) {
36
            return;
37
        }
38
39 2
        foreach ($options as $action => $value) {
40 2
            assert(is_callable($value));
41 2
            $value($model, $action);
42
        }
43
    }
44
}
45