mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 01:33:11 +08:00
Removed more functional-php usages
This commit is contained in:
@@ -6,7 +6,6 @@ namespace Shlinkio\Shlink\Core\ShortUrl\Model;
|
||||
|
||||
use Shlinkio\Shlink\Core\Model\DeviceType;
|
||||
|
||||
use function Functional\group;
|
||||
use function trim;
|
||||
|
||||
final class DeviceLongUrlPair
|
||||
@@ -25,27 +24,20 @@ final class DeviceLongUrlPair
|
||||
* * The first one is a list of mapped instances for those entries in the map with non-null value
|
||||
* * The second is a list of DeviceTypes which have been provided with value null
|
||||
*
|
||||
* @param array<string, string> $map
|
||||
* @param array<string, string | null> $map
|
||||
* @return array{array<string, self>, DeviceType[]}
|
||||
*/
|
||||
public static function fromMapToChangeSet(array $map): array
|
||||
{
|
||||
$toRemove = []; // TODO Use when group is removed
|
||||
$toKeep = []; // TODO Use when group is removed
|
||||
$typesWithNullUrl = group($map, static fn (?string $longUrl) => $longUrl === null ? 'remove' : 'keep');
|
||||
|
||||
$deviceTypesToRemove = [];
|
||||
foreach ($typesWithNullUrl['remove'] ?? [] as $deviceType => $_) {
|
||||
$deviceTypesToRemove[] = DeviceType::from($deviceType);
|
||||
}
|
||||
|
||||
$pairsToKeep = [];
|
||||
/**
|
||||
* @var string $deviceType
|
||||
* @var string $longUrl
|
||||
*/
|
||||
foreach ($typesWithNullUrl['keep'] ?? [] as $deviceType => $longUrl) {
|
||||
$pairsToKeep[$deviceType] = self::fromRawTypeAndLongUrl($deviceType, $longUrl);
|
||||
$deviceTypesToRemove = [];
|
||||
|
||||
foreach ($map as $deviceType => $longUrl) {
|
||||
if ($longUrl === null) {
|
||||
$deviceTypesToRemove[] = DeviceType::from($deviceType);
|
||||
} else {
|
||||
$pairsToKeep[$deviceType] = self::fromRawTypeAndLongUrl($deviceType, $longUrl);
|
||||
}
|
||||
}
|
||||
|
||||
return [$pairsToKeep, $deviceTypesToRemove];
|
||||
|
||||
@@ -10,10 +10,10 @@ use Shlinkio\Shlink\Core\Model\DeviceType;
|
||||
|
||||
use function array_keys;
|
||||
use function array_values;
|
||||
use function Functional\every;
|
||||
use function is_array;
|
||||
use function Shlinkio\Shlink\Core\contains;
|
||||
use function Shlinkio\Shlink\Core\enumValues;
|
||||
use function Shlinkio\Shlink\Core\every;
|
||||
|
||||
class DeviceLongUrlsValidator extends AbstractValidator
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user