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