Test Failed
Push — master ( ce60e5...378563 )
by Julien
12:41 queued 07:49
created

Action   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 36.36%

Importance

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

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 1
    public function notify(string $type, ModelInterface $model)
25
    {
26 1
        if (!$this->isEnabled()) {
27
            return;
28
        }
29
        
30 1
        if (!$this->mustTakeAction($type)) {
31 1
            return;
32
        }
33
34
        $options = $this->getOptions($type);
35
        if (empty($options)) {
36
            return;
37
        }
38
39
        foreach ($options as $action => $value) {
40
            assert(is_callable($value));
41
            $value($model, $action);
42
        }
43
    }
44
}
45