fd9f98b3bf5d847f831eafdedb804def7a8996a9
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\option\user\group;
3
4 /**
5 * User group option type implementation for integer input fields.
6 *
7 * The merge of option values returns -1 if all values are -1 otherwise the lowest
8 * value.
9 *
10 * @author Marcel Werk
11 * @copyright 2001-2016 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\System\Option\User\Group
14 */
15 class InfiniteInverseIntegerUserGroupOptionType extends InverseIntegerUserGroupOptionType {
16 /**
17 * @inheritDoc
18 */
19 public function merge($defaultValue, $groupValue) {
20 if ($groupValue == -1 || $defaultValue == $groupValue) {
21 return null;
22 }
23
24 if ($defaultValue == -1) {
25 return $groupValue;
26 }
27
28 return min($defaultValue, $groupValue);
29 }
30
31 /**
32 * @inheritDoc
33 */
34 public function compare($value1, $value2) {
35 if ($value1 == $value2) {
36 return 0;
37 }
38
39 if ($value1 == -1) {
40 return 1;
41 }
42 else if ($value2 == -1) {
43 return -1;
44 }
45
46 return ($value1 < $value2) ? 1 : -1;
47 }
48 }