1 | <?php |
||
7 | class IO |
||
8 | { |
||
9 | /** @var IOHandlerInterface */ |
||
10 | protected $handler; |
||
11 | |||
12 | /** |
||
13 | * IO constructor. |
||
14 | * |
||
15 | * @param IOHandlerInterface $handler |
||
16 | */ |
||
17 | 50 | public function __construct(IOHandlerInterface $handler) |
|
21 | |||
22 | /** |
||
23 | * Override the IO Handler. |
||
24 | * |
||
25 | * @param IOHandlerInterface $handler |
||
26 | */ |
||
27 | 50 | public function setHandler(IOHandlerInterface $handler) |
|
31 | |||
32 | /** |
||
33 | * Ask a question. |
||
34 | * |
||
35 | * @throws AskException |
||
36 | * @param string $name |
||
37 | * @param string $question |
||
38 | * @param string $default |
||
39 | * @param bool $required |
||
40 | * @return string |
||
41 | */ |
||
42 | 12 | public function ask(string $name, string $question, string $default = '', bool $required = false) |
|
59 | |||
60 | /** |
||
61 | * Output a message to the console. |
||
62 | * |
||
63 | * @param string $message |
||
64 | */ |
||
65 | 2 | public function out(string $message) |
|
69 | |||
70 | /** |
||
71 | * Get input from the console. |
||
72 | * |
||
73 | * @param string $question |
||
74 | * @param string $default |
||
75 | * @return mixed |
||
76 | */ |
||
77 | 14 | public function in(string $question, string $default = '') |
|
83 | } |
||
84 |