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 |
||
0 ignored issues
–
show
|
|||
34 | $this->_record->save(); |
||
35 | } |
||
36 | } |
||
37 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.