Completed
Push — master ( df8184...e3b994 )
by Aydin
02:31
created

examples/input-advanced.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use PhpSchool\CliMenu\CliMenu;
4
use PhpSchool\CliMenu\Builder\CliMenuBuilder;
5
6
require_once(__DIR__ . '/../vendor/autoload.php');
7
8
$itemCallable = function (CliMenu $menu) {
9
    $username = $menu->askText()
10
        ->setPromptText('Enter username')
11
        ->setPlaceholderText('alice')
12
        ->ask();
13
14
    $age = $menu->askNumber()
15
        ->setPromptText('Enter age')
16
        ->setPlaceholderText('28')
17
        ->ask();
18
19
    $password = $menu->askPassword()
20
        ->setPromptText('Enter password')
21
        ->ask();
22
23
    var_dump($username->fetch(), $age->fetch(), $password->fetch());
0 ignored issues
show
Security Debugging Code introduced by Aydin Hassan
var_dump($username->fetc...), $password->fetch()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
24
};
25
26
$menu = (new CliMenuBuilder)
27
    ->setTitle('User Manager')
28
    ->addItem('Create New User', $itemCallable)
29
    ->addLineBreak('-')
30
    ->build();
31
32
$menu->open();
33