Passed
Push — master ( 750b2b...2c58c8 )
by Julien
05:58
created

SoftDelete   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 94.12%

Importance

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

6 Methods

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