ToggleCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 4
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 5 2
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
    private int $toggle = 1;
15
16
    /**
17
     * Switches from one command to another
18
     * -------------------------------------
19
     * Переключает с одной команды на другую
20
     *
21
     * @return void
22
     */
23
    public function execute(): void
24
    {
25
        $command = ($this->toggle % 2) ? new TurnOnCommand() : new TurnOffCommand();
26
        $this->toggle++;
27
        $command->execute();
28
    }
29
}
30