diff --git a/Command/Command.php b/Command/Command.php index 60e09ad..17d639e 100644 --- a/Command/Command.php +++ b/Command/Command.php @@ -1,6 +1,6 @@ what = (string)$what; - } - - public function execute() - { - echo $this->what; - } -} \ No newline at end of file diff --git a/Command/HelloCommand.php b/Command/HelloCommand.php new file mode 100644 index 0000000..1ba3ecb --- /dev/null +++ b/Command/HelloCommand.php @@ -0,0 +1,30 @@ +output = $console; + } + + public function execute() + { + // sometimes, there is no receiver and this is the command which + // does all the work + $this->output->write('Hello World'); + } + +} \ No newline at end of file diff --git a/Command/Invoker.php b/Command/Invoker.php new file mode 100644 index 0000000..75d7a23 --- /dev/null +++ b/Command/Invoker.php @@ -0,0 +1,34 @@ +command = $cmd; + } + + public function run() + { + // here is a key feature of the invoker + // the invoker is the same whatever is the command + $this->command->execute(); + } + +} \ No newline at end of file diff --git a/Command/Receiver.php b/Command/Receiver.php new file mode 100644 index 0000000..a9b6516 --- /dev/null +++ b/Command/Receiver.php @@ -0,0 +1,20 @@ +