PluginProbe
User Access Manager / 2.2.23
User Access Manager v2.2.23
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Config/SelectionConfigParameter.php +40 -2 2.3.142.2.23 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * SelectionConfigParameter.php
4 + *
5 + * The SelectionConfigParameter class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Config;
@@ -5,24 +18,49 @@
5 18 namespace UserAccessManager\Config;
6 19
7 20 use Exception;
8 21
22 +/**
23 + * Class SelectionConfigParameter
24 + *
25 + * @package UserAccessManager\Config
26 + */
9 27 class SelectionConfigParameter extends ConfigParameter
10 28 {
11 29 /**
30 + * @var array
31 + */
32 + private $selections;
33 +
34 + /**
35 + * SelectionConfigParameter constructor.
36 + * @param string $id
37 + * @param mixed $defaultValue
38 + * @param array $selections
12 39 * @throws Exception
13 40 */
14 - public function __construct(string $id, mixed $defaultValue, private array $selections)
41 + public function __construct(string $id, $defaultValue, array $selections)
15 42 {
43 + $this->selections = $selections;
44 +
16 45 parent::__construct($id, $defaultValue);
17 46 }
18 47
19 - public function isValidValue(mixed $value): bool
48 + /**
49 + * Checks if the value is part of the selection.
50 + * @param mixed $value
51 + * @return bool
52 + */
53 + public function isValidValue($value): bool
20 54 {
21 55 $map = array_flip($this->selections);
22 56 return (isset($map[$value]) === true);
23 57 }
24 58
59 + /**
60 + * Returns the available selections.
61 + * @return array
62 + */
25 63 public function getSelections(): array
26 64 {
27 65 return $this->selections;
28 66 }