feat: torrentio api for movie results
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Client\Rule\DownloadOptionFilter;
|
||||
|
||||
use App\Torrentio\Result\ResultFactory;
|
||||
|
||||
class Resolution
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
public string $expectedValue
|
||||
) {}
|
||||
|
||||
public function __invoke(ResultFactory $result): bool
|
||||
{
|
||||
return $result->resolution === $this->expectedValue;
|
||||
}
|
||||
}
|
||||
34
src/Torrentio/Client/Rule/RuleEngine.php
Normal file
34
src/Torrentio/Client/Rule/RuleEngine.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Client\Rule;
|
||||
|
||||
class RuleEngine
|
||||
{
|
||||
private array $rules = [];
|
||||
|
||||
public function addRule(callable $rule): void
|
||||
{
|
||||
$this->rules[] = $rule;
|
||||
}
|
||||
|
||||
public function validateAny($fact): bool
|
||||
{
|
||||
foreach ($this->rules as $rule) {
|
||||
if ($rule($fact)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function validateAll($fact): bool
|
||||
{
|
||||
foreach ($this->rules as $rule) {
|
||||
if (!$rule($fact)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user