This repository was archived by the owner on Mar 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathField.php
More file actions
71 lines (62 loc) · 1.33 KB
/
Field.php
File metadata and controls
71 lines (62 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Copyright (C) GrizzIT, Inc. All rights reserved.
* See LICENSE for license details.
*/
namespace Ulrack\Cli\Component\Element\Form;
use Ulrack\Cli\Common\Io\ReaderInterface;
use Ulrack\Cli\Common\Element\ElementInterface;
use Ulrack\Cli\Common\Element\Form\FieldInterface;
class Field implements FieldInterface
{
/**
* Contains the reader to read the input.
*
* @var ReaderInterface
*/
private $reader;
/**
* Contains the label for the field.
*
* @var ElementInterface
*/
private $label;
/**
* Contains the input when it is set.
*
* @var mixed
*/
private $input = '';
/**
* Constructor.
*
* @param ReaderInterface $reader
* @param ElementInterface $label
*/
public function __construct(
ReaderInterface $reader,
ElementInterface $label
) {
$this->reader = $reader;
$this->label = $label;
}
/**
* Processes the field and stores the users input.
*
* @return void
*/
public function render(): void
{
$this->label->render();
$this->input = $this->reader->read();
}
/**
* Retrieves the input of the element.
*
* @return string
*/
public function getInput(): string
{
return $this->input;
}
}