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

examples/input-number.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
    $number = $menu->askNumber();
10
    $number->getStyle()
11
        ->setBg('180')
12
        ->setFg('245');
13
    
14
    $result = $number->setPlaceholderText(10)
15
        ->ask();
16
17
    var_dump($result->fetch());
0 ignored issues
show
Security Debugging Code introduced by Aydin Hassan
var_dump($result->fetch()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
18
};
19
20
$menu = (new CliMenuBuilder)
21
    ->setTitle('Basic CLI Menu')
22
    ->addItem('Enter number', $itemCallable)
23
    ->addItem('Second Item', $itemCallable)
24
    ->addItem('Third Item', $itemCallable)
25
    ->setBackgroundColour('237')
26
    ->setForegroundColour('156')
27
    ->setBorder(0, 0, 0, 2, '165')
28
    ->setPaddingTopBottom(4)
29
    ->setPaddingLeftRight(8)
30
    ->addLineBreak('-')
31
    ->setMarginAuto()
32
    ->build();
33
34
$menu->open();
35