Test Failed
Push — master ( b1cf76...d8fe36 )
by Julien
08:28
created

SoftDelete   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 70.59%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 13
c 1
b 0
f 0
dl 0
loc 39
ccs 12
cts 17
cp 0.7059
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getField() 0 3 1
A getValue() 0 3 1
A setValue() 0 3 1
A setField() 0 3 1
A __construct() 0 5 1
A notify() 0 8 2
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
use Zemit\Mvc\Model\Behavior\Traits\SkippableTrait;
17
18
/**
19
 * {@inheritDoc}
20
 */
21
class SoftDelete extends Behavior\SoftDelete
22
{
23
    use SkippableTrait;
24
    
25 56
    public function setField(string $field): void
26
    {
27 56
        $this->options['field'] = $field;
28
    }
29
    
30
    public function getField(): string
31
    {
32
        return $this->options['field'];
33
    }
34
    
35 56
    public function setValue(int $value): void
36
    {
37 56
        $this->options['value'] = $value;
38
    }
39
    
40
    public function getValue(): int
41
    {
42
        return $this->options['value'];
43
    }
44
    
45 56
    public function __construct(array $options = [])
46
    {
47 56
        parent::__construct($options);
48 56
        $this->setField($options['field'] ?? 'deleted');
49 56
        $this->setValue($options['value'] ?? 1);
50
    }
51
    
52 3
    public function notify(string $type, ModelInterface $model): ?bool
53
    {
54 3
        if (!$this->isEnabled()) {
55
            return null;
56
        }
57
        
58 3
        parent::notify($type, $model);
59 3
        return null;
60
    }
61
}
62