1 | <?php |
||
16 | class Composite extends Command implements IComposite { |
||
17 | /** |
||
18 | * an array of commands |
||
19 | * |
||
20 | * @var ICommand[] |
||
21 | */ |
||
22 | private $commands; |
||
23 | |||
24 | 27 | public function __construct() |
|
28 | |||
29 | /** |
||
30 | * this method will call all commands added to this class in order of |
||
31 | * addition |
||
32 | * |
||
33 | * @throws Exception |
||
34 | */ |
||
35 | 19 | protected function _execute() |
|
41 | |||
42 | /** |
||
43 | * this method can be used to add multiple commands that will be used in the |
||
44 | * execute() method |
||
45 | * |
||
46 | * @param |
||
47 | * command a concrete command that implements the ICommand |
||
48 | * interface |
||
49 | */ |
||
50 | 22 | public function add(ICommand $command) |
|
54 | |||
55 | /** |
||
56 | * Removes a command if it is part of the composite (based on identity ===) |
||
57 | * |
||
58 | * @param ICommand $command |
||
59 | * @return boolean |
||
60 | */ |
||
61 | 1 | public function remove(ICommand $command) |
|
74 | |||
75 | /** |
||
76 | * does this contain a command (based on identity ===) |
||
77 | * |
||
78 | * @param ICommand $command |
||
79 | * @return boolean |
||
80 | */ |
||
81 | 1 | public function contains(ICommand $command) |
|
92 | |||
93 | /** |
||
94 | * (non-PHPdoc) |
||
95 | * |
||
96 | * @see \izzum\IComposite::count() |
||
97 | */ |
||
98 | 1 | public function count() |
|
102 | |||
103 | 5 | public function toString() |
|
115 | } |