Flash   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 31
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A display() 0 25 1
1
<?php
2
3
namespace PhpSchool\CliMenu\Dialogue;
4
5
use PhpSchool\Terminal\NonCanonicalReader;
6
7
/**
8
 * @author Aydin Hassan <[email protected]>
9
 */
10
class Flash extends Dialogue
11
{
12
    /**
13
     * Flash a message on top of the menu which
14
     * disappears on any keystroke.
15
     */
16
    public function display() : void
17
    {
18
        $this->assertMenuOpen();
19
20
        $this->terminal->moveCursorToRow($this->y);
21
22
        $this->emptyRow();
23
24
        $this->write(sprintf(
25
            "%s%s%s%s%s\n",
26
            $this->style->getColoursSetCode(),
27
            str_repeat(' ', $this->style->getPaddingLeftRight()),
28
            $this->text,
29
            str_repeat(' ', $this->style->getPaddingLeftRight()),
30
            $this->style->getColoursResetCode()
31
        ));
32
33
        $this->emptyRow();
34
35
        $this->terminal->moveCursorToTop();
36
37
        $reader = new NonCanonicalReader($this->terminal);
38
        $reader->readCharacter();
39
40
        $this->parentMenu->redraw();
41
    }
42
}
43