429a484a19c36c859cf657c530ae9132c6b965d7
[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 com.woltlab.wcf
14 * @subpackage system.option.user.group
15 * @category Community Framework
16 */
17 class InfiniteInverseIntegerUserGroupOptionType extends InverseIntegerUserGroupOptionType {
18 /**
19 * @see \wcf\system\option\user\group\IUserGroupOptionType::merge()
20 */
21 public function merge($defaultValue, $groupValue) {
22 if ($groupValue == -1 || $defaultValue == $groupValue) {
23 return null;
24 }
25
26 if ($defaultValue == -1) {
27 return $groupValue;
28 }
29
30 return min($defaultValue, $groupValue);
31 }
32
33 /**
34 * @see \wcf\system\option\IOptionType::compare()
35 */
36 public function compare($value1, $value2) {
37 if ($value1 == $value2) {
38 return 0;
39 }
40
41 if ($value1 == -1) {
42 return 1;
43 }
44 else if ($value2 == -1) {
45 return -1;
46 }
47
48 return ($value1 < $value2) ? 1 : -1;
49 }
50 }