Completed
Pull Request — master (#78)
by Aydin
02:26
created

Text::getValidationFailedText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace PhpSchool\CliMenu\Input;
4
5
/**
6
 * @author Aydin Hassan <[email protected]>
7
 */
8
class Text implements Input
9
{
10
    /**
11
     * @var InputIO
12
     */
13
    private $inputIO;
14
15
    /**
16
     * @var string
17
     */
18
    private $promptText = 'Enter text:';
19
20
    /**
21
     * @var string
22
     */
23
    private $validationFailedText = 'Invalid, try again';
24
25
    /**
26
     * @var string
27
     */
28
    private $placeholderText = '';
29
30
    public function __construct(InputIO $inputIO)
31
    {
32
        $this->inputIO = $inputIO;
33
    }
34
35
    public function setPromptText(string $promptText) : Input
36
    {
37
        $this->promptText = $promptText;
38
39
        return $this;
40
    }
41
42
    public function getPromptText() : string
43
    {
44
        return $this->promptText;
45
    }
46
47
    public function setValidationFailedText(string $validationFailedText) : Input
48
    {
49
        $this->validationFailedText = $validationFailedText;
50
51
        return $this;
52
    }
53
54
    public function getValidationFailedText() : string
55
    {
56
        return $this->validationFailedText;
57
    }
58
59
    public function setPlaceholderText(string $placeholderText) : Input
60
    {
61
        $this->placeholderText = $placeholderText;
62
63
        return $this;
64
    }
65
66
    public function getPlaceholderText() : string
67
    {
68
        return $this->placeholderText;
69
    }
70
71
    public function ask() : InputResult
72
    {
73
        return $this->inputIO->collect($this);
74
    }
75
76
    public function validate(string $input) : bool
77
    {
78
        return !empty($input);
79
    }
80
81
    public function format(string $value) : string
82
    {
83
        return $value;
84
    }
85
}
86