1 | <?php |
||
17 | class Std |
||
18 | { |
||
19 | /** |
||
20 | * @var resource |
||
21 | */ |
||
22 | private $handle; |
||
23 | |||
24 | /** |
||
25 | * @param string $stream |
||
26 | */ |
||
27 | public function __construct($stream = 'php://stdin') |
||
31 | |||
32 | /** |
||
33 | * @return string |
||
34 | */ |
||
35 | public function value() |
||
39 | |||
40 | public function __destruct() |
||
44 | |||
45 | /** |
||
46 | * Allow direct access to the corresponding input stream of the PHP process. |
||
47 | * |
||
48 | * @param string $prompt |
||
49 | * @param string $validation A regex pattern |
||
50 | * |
||
51 | * <code> |
||
52 | * |
||
53 | * Have a look at the examples for $validation: |
||
54 | * |
||
55 | * Regular Expression | Will match... |
||
56 | * ------------------------------------------------------------- |
||
57 | * .* | Not empty |
||
58 | * foo | The string "foo" |
||
59 | * ^foo | "foo" at the start of a string |
||
60 | * foo$ | "foo" at the end of a string |
||
61 | * ^foo$ | "foo" when it is alone on a string |
||
62 | * [abc] | a, b, or c |
||
63 | * [a-z] | Any lowercase letter |
||
64 | * [^A-Z] | Any character that is not a uppercase letter |
||
65 | * (gif|jpg) | Matches either "gif" or "jpeg" |
||
66 | * [a-z]+ | One or more lowercase letters |
||
67 | * [0-9\.\-] | Аny number, dot, or minus sign |
||
68 | * |
||
69 | * </code> |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function read($prompt, $validation = "/.*/") |
||
92 | |||
93 | /** |
||
94 | * @param string $validation A regex pattern |
||
95 | * @param string $value |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | public function valid($validation, $value) |
||
103 | |||
104 | /** |
||
105 | * @param string $prompt |
||
106 | */ |
||
107 | public function view($prompt) |
||
111 | } |
||
112 |