-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.php
executable file
·50 lines (37 loc) · 1.85 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types = 1);
namespace Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl;
use Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl\CeilingFan\CeilingFan;
use Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl\CeilingFan\CeilingFanHighCommand;
use Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl\CeilingFan\CeilingFanMediumCommand;
use Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl\CeilingFan\CeilingFanOffCommand;
use Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl\Light\Light;
use Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl\Light\LightOffCommand;
use Maksi\HeadFirstDesignPattern\Command\UndoRemoteControl\Light\LightOnCommand;
require_once '../../../vendor/autoload.php';
$remoteControl = new RemoteControlWithUndo();
$livingRoomLight = new Light('Living Room');
$livingRoomLightOn = new LightOnCommand($livingRoomLight);
$livingRoomLightOff = new LightOffCommand($livingRoomLight);
$remoteControl->setCommand(0, $livingRoomLightOn, $livingRoomLightOff);
$remoteControl->onButtonWasPushed(0);
$remoteControl->offButtonWasPushed(0);
echo $remoteControl;
$remoteControl->undoButtonWasPushed();
$remoteControl->offButtonWasPushed(0);
$remoteControl->onButtonWasPushed(0);
echo $remoteControl;
$remoteControl->undoButtonWasPushed();
$ceilingFan = new CeilingFan('Living Room');
$ceilingFanMedium = new CeilingFanMediumCommand($ceilingFan);
$ceilingFanHigh = new CeilingFanHighCommand($ceilingFan);
$ceilingFanOff = new CeilingFanOffCommand($ceilingFan);
$remoteControl->setCommand(0, $ceilingFanMedium, $ceilingFanOff);
$remoteControl->setCommand(1, $ceilingFanHigh, $ceilingFanOff);
$remoteControl->onButtonWasPushed(0);
$remoteControl->offButtonWasPushed(0);
echo $remoteControl;
$remoteControl->undoButtonWasPushed();
$remoteControl->onButtonWasPushed(1);
echo $remoteControl;
$remoteControl->undoButtonWasPushed();