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

Action::notify()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 11.4436

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 18
ccs 4
cts 11
cp 0.3636
rs 9.6111
cc 5
nc 5
nop 2
crap 11.4436
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