1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19

20
/**
21
 * Encapsulates an input request.
22
 *
23
 * @author Stefan Bodewig <stefan.bodewig@epost.de>
24
 *
25
 * @package phing.input
26
 */
27
class MultipleChoiceInputRequest extends InputRequest
28
{
29
    /**
30
     * @var array $choises
31
     */
32
    protected $choices = [];
33

34
    /**
35
     * @param string $prompt The prompt to show to the user.  Must not be null.
36
     * @param array $choices holds all input values that are allowed.
37
     *                        Must not be null.
38
     */
39 1
    public function __construct($prompt, $choices)
40
    {
41 1
        parent::__construct($prompt);
42 1
        $this->choices = $choices;
43
    }
44

45
    /**
46
     * @return array The possible values.
47
     */
48 1
    public function getChoices()
49
    {
50 1
        return $this->choices;
51
    }
52

53
    /**
54
     * @return bool true if the input is one of the allowed values.
55
     */
56 0
    public function isInputValid()
57
    {
58 0
        return in_array($this->getInput(), $this->choices); // not strict (?)
59
    }
60
}

Read our documentation on viewing source code .

Loading