Completed
Pull Request — master (#222)
by Alejandro
09:31
created

AskUtilsTrait::askRequired()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 3
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\Installer\Util;
5
6
use Shlinkio\Shlink\Installer\Exception\MissingRequiredOptionException;
7
use Symfony\Component\Console\Style\SymfonyStyle;
8
9
trait AskUtilsTrait
10
{
11
    /**
12
     * @return mixed
13
     */
14
    private function askRequired(SymfonyStyle $io, string $optionName, string $question)
15
    {
16
        return $io->ask($question, null, function ($value) use ($optionName) {
17
            if (empty($value)) {
18
                throw MissingRequiredOptionException::fromOption($optionName);
19
            };
20
        });
21
    }
22
}
23