![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/LeadBundle/Deduplicate/Helper/ |
<?php namespace Mautic\LeadBundle\Deduplicate\Helper; use Mautic\LeadBundle\Deduplicate\Exception\ValueNotMergeableException; class MergeValueHelper { /** * @param mixed $newerValue * @param mixed $olderValue * @param mixed $currentValue * @param mixed $defaultValue * @param bool $newIsAnonymous * * @return mixed * * @throws ValueNotMergeableException */ public static function getMergeValue($newerValue, $olderValue, $currentValue = null, $defaultValue = null, $newIsAnonymous = false) { if ($newerValue === $olderValue) { throw new ValueNotMergeableException($newerValue, $olderValue); } if (null !== $currentValue && $newerValue === $currentValue) { throw new ValueNotMergeableException($newerValue, $olderValue); } $isDefaultValue = null !== $defaultValue && $newerValue === $defaultValue; if (self::isNotEmpty($newerValue) && !($newIsAnonymous && $isDefaultValue)) { return $newerValue; } if (self::isNotEmpty($olderValue)) { return $olderValue; } throw new ValueNotMergeableException($newerValue, $olderValue); } public static function isNotEmpty($value): bool { return null !== $value && '' !== $value; } }