Completed
Push — master ( 63d3c0...3a8a58 )
by Korotkov
02:41 queued 12s
created

ToggleCommand::getToggle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author  : Jagepard <[email protected]>
7
 * @license https://mit-license.org/ MIT
8
 */
9
10
namespace Behavioral\Command;
11
12
class ToggleCommand implements CommandInterface
13
{
14
    /**
15
     * @var integer
16
     */
17
    private $toggle = 1;
18
19
    public function execute(): void
20
    {
21
        $command = ($this->toggle % 2) ? new TurnOnCommand() : new TurnOffCommand();
22
        $this->toggle++;
23
        $command->execute();
24
    }
25
}
26