adrema/app/Lib/Editor/ConditionResolver.php

29 lines
703 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;
/**
2024-07-14 21:44:33 +02:00
* @return array<int, mixed>
*/
2024-07-14 19:29:42 +02:00
public function makeBlocks(EditorData $data): array
{
2024-07-14 19:29:42 +02:00
return array_filter($data->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
}
}