Passed
Push — master ( cc7747...d2190f )
by Mihail
10:36
created

FormTurn   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 25
rs 10
c 1
b 1
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A update() 0 7 1
1
<?php
2
3
namespace Apps\Model\Admin\Application;
4
5
use Apps\ActiveRecord\App;
6
use Ffcms\Core\Arch\Model;
7
8
/**
9
 * Class FormTurn. Turn on/off model for application object
10
 * @package Apps\Model\Admin\Application
11
 */
12
class FormTurn extends Model
13
{
14
    private $_record;
15
16
    /**
17
     * FormTurn constructor. Pass app object inside.
18
     * @param App $record
19
     */
20
    public function __construct(App $record)
21
    {
22
        $this->_record = $record;
23
        parent::__construct(true);
24
    }
25
26
    /**
27
     * Switch app status to inverse
28
     */
29
    public function update()
30
    {
31
        $status = $this->_record->disabled;
32
33
        $this->_record->disabled = (int)!$status; // magic inside: bool to int and reverse - 0 => 1, 1 => 0
34
        $this->_record->save();
35
    }
36
}