PluginProbe
User Access Manager / 2.2.3
User Access Manager v2.2.3
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/UserGroup/UserGroup.php +64 -7 2.3.132.2.3 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * UserGroup.php
4 + *
5 + * The UserGroup 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\UserGroup;
@@ -11,16 +24,37 @@
11 24 use UserAccessManager\Util\Util;
12 25 use UserAccessManager\Wrapper\Php;
13 26 use UserAccessManager\Wrapper\Wordpress;
14 27
28 +/**
29 + * Class UserGroup
30 + *
31 + * @package UserAccessManager\UserGroup
32 + */
15 33 class UserGroup extends AbstractUserGroup
16 34 {
17 35 const USER_GROUP_TYPE = 'UserGroup';
18 36
19 - protected ?string $type = self::USER_GROUP_TYPE;
20 - protected ?string $ipRange = null;
37 + /**
38 + * @var string
39 + */
40 + protected $type = self::USER_GROUP_TYPE;
21 41
22 42 /**
43 + * @var string
44 + */
45 + protected $ipRange = null;
46 +
47 + /**
48 + * UserGroup constructor.
49 + * @param Php $php
50 + * @param Wordpress $wordpress
51 + * @param Database $database
52 + * @param MainConfig $config
53 + * @param Util $util
54 + * @param ObjectHandler $objectHandler
55 + * @param AssignmentInformationFactory $assignmentInformationFactory
56 + * @param null|string $id
23 57 * @throws UserGroupTypeException
24 58 */
25 59 public function __construct(
26 60 Php $php,
@@ -29,9 +63,9 @@
29 63 MainConfig $config,
30 64 Util $util,
31 65 ObjectHandler $objectHandler,
32 66 AssignmentInformationFactory $assignmentInformationFactory,
33 - int|string|null $id = null
67 + $id = null
34 68 ) {
35 69 parent::__construct(
36 70 $php,
37 71 $wordpress,
@@ -46,24 +80,41 @@
46 80 $this->load($id);
47 81 }
48 82 }
49 83
50 - public function getIpRange(): array|string|null
84 + /**
85 + * Returns the ip range.
86 + * @return array|string
87 + */
88 + public function getIpRange()
51 89 {
52 90 return $this->ipRange;
53 91 }
54 92
93 + /**
94 + * Returns the ip range as array
95 + * @return array
96 + */
55 97 public function getIpRangeArray(): array
56 98 {
57 - return explode(';', (string) $this->ipRange);
99 + return explode(';', $this->ipRange);
58 100 }
59 101
60 - public function setIpRange(array|string $ipRange): void
102 + /**
103 + * Sets the ip range.
104 + * @param string|array $ipRange The new ip range.
105 + */
106 + public function setIpRange($ipRange)
61 107 {
62 108 $this->ipRange = (is_array($ipRange) === true) ? implode(';', $ipRange) : $ipRange;
63 109 }
64 110
65 - public function load(int|string $id): bool
111 + /**
112 + * Loads the user group.
113 + * @param int|string $id
114 + * @return bool
115 + */
116 + public function load($id): bool
66 117 {
67 118 $query = $this->database->prepare(
68 119 "SELECT *
69 120 FROM {$this->database->getUserGroupTable()}
@@ -87,8 +138,12 @@
87 138
88 139 return false;
89 140 }
90 141
142 + /**
143 + * Saves the user group.
144 + * @return bool
145 + */
91 146 public function save(): bool
92 147 {
93 148 if ($this->id === null) {
94 149 $return = $this->database->insert(
@@ -122,8 +177,10 @@
122 177 return ($return !== false);
123 178 }
124 179
125 180 /**
181 + * Deletes the user group.
182 + * @return bool
126 183 * @throws Exception
127 184 */
128 185 public function delete(): bool
129 186 {