Completed
Pull Request — master (#81)
by Aydin
03:36
created

Flash   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 5
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B display() 0 26 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->getUnselectedSetCode(),
27
            str_repeat(' ', $this->style->getPadding()),
28
            $this->text,
29
            str_repeat(' ', $this->style->getPadding()),
30
            $this->style->getUnselectedUnsetCode()
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