Passed
Pull Request — master (#4)
by Korotkov
02:42
created

ToggleCommand::getToggle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @license   https://mit-license.org/ MIT
8
 */
9
10
namespace Behavioral\Command;
11
12
/**
13
 * Class ToggleCommand
14
 * @package Behavioral\Command
15
 */
16
class ToggleCommand implements CommandInterface
17
{
18
19
    /**
20
     * @var int
21
     */
22
    protected $toggle = 1;
23
24
    /**
25
     * @param DeviceInterface $device
26
     */
27
    public function execute(DeviceInterface $device): void
28
    {
29
        ($this->toggle % 2) ? $device->turnOn() : $device->turnOff();
30
        $this->toggle++;
31
    }
32
}
33