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

AskUtilsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

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
    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