nuxsmin /
sysPass
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * sysPass |
||
| 4 | * |
||
| 5 | * @author nuxsmin |
||
| 6 | * @link https://syspass.org |
||
| 7 | * @copyright 2012-2019, Rubén Domínguez nuxsmin@$syspass.org |
||
| 8 | * |
||
| 9 | * This file is part of sysPass. |
||
| 10 | * |
||
| 11 | * sysPass is free software: you can redistribute it and/or modify |
||
| 12 | * it under the terms of the GNU General Public License as published by |
||
| 13 | * the Free Software Foundation, either version 3 of the License, or |
||
| 14 | * (at your option) any later version. |
||
| 15 | * |
||
| 16 | * sysPass is distributed in the hope that it will be useful, |
||
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 19 | * GNU General Public License for more details. |
||
| 20 | * |
||
| 21 | * You should have received a copy of the GNU General Public License |
||
| 22 | * along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
||
| 23 | */ |
||
| 24 | |||
| 25 | namespace SP\Mvc\View\Components; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Class SelectItem |
||
| 29 | * |
||
| 30 | * @package SP\Mvc\View\Components |
||
| 31 | */ |
||
| 32 | final class SelectItem |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * @var int |
||
| 36 | */ |
||
| 37 | protected $id; |
||
| 38 | /** |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | protected $name; |
||
| 42 | /** |
||
| 43 | * @var mixed |
||
| 44 | */ |
||
| 45 | protected $item; |
||
| 46 | /** |
||
| 47 | * @var bool |
||
| 48 | */ |
||
| 49 | protected $selected = false; |
||
| 50 | /** |
||
| 51 | * @var bool |
||
| 52 | */ |
||
| 53 | protected $skip = false; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * SelectItem constructor. |
||
| 57 | * |
||
| 58 | * @param int $id |
||
| 59 | * @param string $name |
||
| 60 | * @param null $item |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 61 | */ |
||
| 62 | public function __construct($id, $name, $item = null) |
||
| 63 | { |
||
| 64 | $this->id = is_numeric($id) ? (int)$id : $id; |
||
|
0 ignored issues
–
show
|
|||
| 65 | $this->name = (string)$name; |
||
| 66 | $this->item = $item; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return int |
||
| 71 | */ |
||
| 72 | public function getId() |
||
| 73 | { |
||
| 74 | return $this->id; |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | public function getName() |
||
| 81 | { |
||
| 82 | return $this->name; |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @return bool |
||
| 87 | */ |
||
| 88 | public function isSelected() |
||
| 89 | { |
||
| 90 | return $this->selected; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @param bool $selected |
||
| 95 | */ |
||
| 96 | public function setSelected($selected) |
||
| 97 | { |
||
| 98 | $this->selected = (bool)$selected; |
||
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @param $property |
||
| 103 | * |
||
| 104 | * @return mixed |
||
| 105 | */ |
||
| 106 | public function getItemProperty($property) |
||
| 107 | { |
||
| 108 | return null !== $this->item && isset($this->item->{$property}) ? $this->item->{$property} : null; |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @return bool |
||
| 113 | */ |
||
| 114 | public function isSkip() |
||
| 115 | { |
||
| 116 | return $this->skip; |
||
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * @param bool $skip |
||
| 121 | */ |
||
| 122 | public function setSkip($skip) |
||
| 123 | { |
||
| 124 | $this->skip = (bool)$skip; |
||
| 125 | } |
||
| 126 | } |