adrema/app/Lib/Editor/ConditionResolver.php

30 lines
767 B
PHP
Raw Normal View History

<?php
namespace App\Lib\Editor;
abstract class ConditionResolver
{
2024-07-12 00:16:50 +02:00
abstract public function filterCondition(Condition $condition): bool;
/**
* @param array<string, mixed> $content
* @return array<string, mixed>
*/
2024-04-23 23:48:09 +02:00
public function makeBlocks(array $content): array
{
2024-04-20 00:29:32 +02:00
return array_filter(data_get($content, 'blocks', []), fn ($block) => $this->filterBlock($block));
}
2024-04-23 23:48:09 +02:00
/**
2024-04-24 15:39:07 +02:00
* @param array<string, mixed> $block
2024-04-23 23:48:09 +02:00
*/
public function filterBlock(array $block): bool
{
2024-07-12 18:05:11 +02:00
return $this->filterCondition(Condition::withoutMagicalCreationFrom([
'mode' => data_get($block, 'tunes.condition.mode', 'any'),
'ifs' => data_get($block, 'tunes.condition.ifs', []),
]));
2024-04-23 23:48:09 +02:00
}
}