SymfonyStyleTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSymfonyStyle() 0 14 2
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Command/Traits/SymfonyStyleTrait.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Command\Traits;
10
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Console\Style\SymfonyStyle;
14
15
/**
16
 * Trait SymfonyStyleTrait
17
 *
18
 * @package App\Command\Traits
19
 * @author TLe, Tarmo Leppänen <[email protected]>
20
 */
21
trait SymfonyStyleTrait
22
{
23
    /**
24
     * Method to get SymfonyStyle object for console commands.
25
     */
26
    protected function getSymfonyStyle(
27
        InputInterface $input,
28
        OutputInterface $output,
29
        ?bool $clearScreen = null,
30
    ): SymfonyStyle {
31
        $clearScreen ??= true;
32
33
        $io = new SymfonyStyle($input, $output);
34
35
        if ($clearScreen) {
36
            $io->write("\033\143");
37
        }
38
39
        return $io;
40
    }
41
}
42