File: text.php

package info (click to toggle)
php-laravel-prompts 0.1.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: php: 5,928; xml: 14; makefile: 8
file content (21 lines) | stat: -rw-r--r-- 595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

use function Laravel\Prompts\text;

require __DIR__.'/../vendor/autoload.php';

$email = text(
    label: 'What is your email address',
    placeholder: 'E.g. taylor@laravel.com',
    validate: fn ($value) => match (true) {
        strlen($value) === 0 => 'Please enter an email address.',
        ! filter_var($value, FILTER_VALIDATE_EMAIL) => 'Please enter a valid email address.',
        default => null,
    },
    hint: 'We will never share your email address with anyone else.',
    transform: fn ($value) => strtolower($value),
);

var_dump($email);

echo str_repeat(PHP_EOL, 5);