Passed
Push — master ( 6df11d...8e8817 )
by Julien
05:21
created

SoftDelete::notify()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
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\Behavior;
13
14
use Phalcon\Mvc\Model\Behavior;
15
use Phalcon\Mvc\ModelInterface;
16
17
/**
18
 * {@inheritDoc}
19
 */
20
class SoftDelete extends Behavior\SoftDelete
21
{
22
    use SkippableTrait;
23
    
24 4
    public function setField(string $field): void
25
    {
26 4
        $this->options['field'] = $field;
27
    }
28
    
29 2
    public function getField(): string
30
    {
31 2
        return $this->options['field'];
32
    }
33
    
34 4
    public function setValue(int $value): void
35
    {
36 4
        $this->options['value'] = $value;
37
    }
38
    
39 2
    public function getValue(): int
40
    {
41 2
        return $this->options['value'];
42
    }
43
    
44 4
    public function __construct(array $options = [])
45
    {
46 4
        parent::__construct($options);
47 4
        $this->setField($options['field'] ?? 'deleted');
48 4
        $this->setValue($options['value'] ?? 1);
49
    }
50
    
51
    /**
52
     * @return mixed
53
     */
54 4
    public function notify(string $type, ModelInterface $model): ?bool
55
    {
56 4
        if (!$this->isEnabled()) {
57
            return null;
58
        }
59
        
60 4
        return parent::notify($type, $model) ?? null;
61
    }
62
}
63