Completed
Pull Request — master (#25)
by David
02:34
created

AentHelper::subTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheAentMachine;
5
6
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
7
use Symfony\Component\Console\Helper\FormatterHelper;
8
use Symfony\Component\Console\Helper\QuestionHelper;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
/**
13
 * A helper class for the most common questions asked in the console.
14
 */
15
class AentHelper
16
{
17
    /**
18
     * @var InputInterface
19
     */
20
    private $input;
21
    /**
22
     * @var OutputInterface
23
     */
24
    private $output;
25
    /**
26
     * @var QuestionHelper
27
     */
28
    private $questionHelper;
29
    /**
30
     * @var FormatterHelper
31
     */
32
    private $formatterHelper;
33
34
    public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper, FormatterHelper $formatterHelper)
35
    {
36
37
        $this->input = $input;
38
        $this->output = $output;
39
        $this->questionHelper = $questionHelper;
40
        $this->formatterHelper = $formatterHelper;
41
    }
42
43
    private function registerStyle(): void
44
    {
45
        $outputStyle = new OutputFormatterStyle('black', 'cyan', ['bold']);
46
        $this->output->getFormatter()->setStyle('title', $outputStyle);
47
    }
48
49
    /**
50
     * Displays text in a big block
51
     */
52
    public function title(string $title): void
53
    {
54
        $this->registerStyle();
55
        $this->formatterHelper->formatBlock($title, 'title', true);
56
    }
57
58
    /**
59
     * Displays text in a small block
60
     */
61
    public function subTitle(string $title): void
62
    {
63
        $this->registerStyle();
64
        $this->formatterHelper->formatBlock($title, 'title', false);
65
    }
66
}
67