Completed
Pull Request — master (#246)
by Alejandro
05:59
created

AskUtilsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 13
rs 10
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A askRequired() 0 8 2
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 4
    private function askRequired(SymfonyStyle $io, string $optionName, string $question)
15
    {
16
        return $io->ask($question, null, function ($value) use ($optionName) {
17 1
            if (empty($value)) {
18
                throw MissingRequiredOptionException::fromOption($optionName);
19
            };
20
21 1
            return $value;
22 4
        });
23
    }
24
}
25