Select::getFirstSelectedValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Webino (http://webino.sk/)
4
 *
5
 * @link        https://github.com/webino/WebinoDev/ for the canonical source repository
6
 * @copyright   Copyright (c) 2017 Webino, s. r. o. (http://webino.sk/)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDev\Test\Selenium\WebDriver;
11
12
use PHPWebDriver_Support_WebDriverSelect;
13
14
/**
15
 * For mocking PHPWebDriver_WebDriverSimpleItem
16
 */
17
class Select
18
{
19
    /**
20
     * @var PHPWebDriver_Support_WebDriverSelect
21
     */
22
    protected $select;
23
24
    /**
25
     * @param \PHPWebDriver_WebDriverElement $elm
26
     * @param PHPWebDriver_Support_WebDriverSelect|null $select
27
     */
28
    public function __construct($elm, PHPWebDriver_Support_WebDriverSelect $select = null)
29
    {
30
        $this->select = $select ? $select : new PHPWebDriver_Support_WebDriverSelect($elm);
31
    }
32
33
    /**
34
     * @return array
35
     * @throws \PHPWebDriver_NoSuchElementWebDriverError
36
     */
37
    public function getOptions()
38
    {
39
        return $this->select->__get('options');
40
    }
41
42
    /**
43
     * @return array
44
     * @throws \PHPWebDriver_NoSuchElementWebDriverError
45
     */
46
    public function getSelectedOptions()
47
    {
48
        return $this->select->__get('all_selected_options');
49
    }
50
51
    /**
52
     * @return array
53
     * @throws \PHPWebDriver_NoSuchElementWebDriverError
54
     */
55
    public function getFirstSelectedValue()
56
    {
57
        return $this->select->__get('first_selected_value');
58
    }
59
60
    /**
61
     * @return array
62
     * @throws \PHPWebDriver_NoSuchElementWebDriverError
63
     */
64
    public function isMultiple()
65
    {
66
        return $this->select->__get('is_multiple');
67
    }
68
69
    /**
70
     * @param string $value
71
     * @return $this
72
     * @throws \PHPWebDriver_NoSuchElementWebDriverError
73
     */
74
    public function selectByValue($value)
75
    {
76
        $this->select->select_by_value($value);
77
        return $this;
78
    }
79
80
    /**
81
     * @param int $index
82
     * @return $this
83
     * @throws \PHPWebDriver_NoSuchElementWebDriverError
84
     */
85
    public function selectByIndex($index)
86
    {
87
        $this->select->select_by_index($index);
88
        return $this;
89
    }
90
91
    /**
92
     * @param string $text
93
     * @return $this
94
     * @throws \PHPWebDriver_NoSuchElementWebDriverError
95
     */
96
    public function selectByText($text)
97
    {
98
        $this->select->select_by_visible_text($text);
99
        return $this;
100
    }
101
102
    /**
103
     * @return $this
104
     * @throws \PHPWebDriver_NotImplementedError
105
     */
106
    public function deselectAll()
107
    {
108
        $this->select->deselect_all();
109
        return $this;
110
    }
111
112
    /**
113
     * @param string $value
114
     * @return $this
115
     * @throws \PHPWebDriver_NotImplementedError
116
     */
117
    public function deselectByValue($value)
118
    {
119
        $this->select->deselect_by_value($value);
120
        return $this;
121
    }
122
123
    /**
124
     * @param int $index
125
     * @return $this
126
     * @throws \PHPWebDriver_NotImplementedError
127
     */
128
    public function deselectByIndex($index)
129
    {
130
        $this->select->deselect_by_index($index);
131
        return $this;
132
    }
133
134
    /**
135
     * @param string $text
136
     * @return $this
137
     * @throws \PHPWebDriver_NotImplementedError
138
     */
139
    public function deselectByText($text)
140
    {
141
        $this->select->deselect_by_visible_text($text);
142
        return $this;
143
    }
144
}
145