adrema/app/Form/Matchers/SingleValueMatcher.php

31 lines
684 B
PHP
Raw Normal View History

<?php
namespace App\Form\Matchers;
2024-07-12 00:16:50 +02:00
use App\Lib\Editor\Comparator;
class SingleValueMatcher extends Matcher
{
2024-07-12 00:16:50 +02:00
public function matches(Comparator $comparator, mixed $value): bool
{
2024-07-12 00:16:50 +02:00
if ($comparator === Comparator::EQUAL && $value === $this->value) {
return true;
}
2024-07-12 00:16:50 +02:00
if ($comparator === Comparator::NOTEQUAL && $value !== $this->value) {
return true;
}
2024-07-12 00:16:50 +02:00
if ($comparator === Comparator::IN && in_array($this->value, $value)) {
return true;
}
2024-07-12 00:16:50 +02:00
if ($comparator === Comparator::NOTIN && !in_array($this->value, $value)) {
return true;
}
return false;
}
}