Files
2026-04-04 12:35:56 +11:00

35 lines
679 B
PHP

<?php
namespace App\Dto\Scraping;
use JsonSerializable;
class MatchRuleDto implements JsonSerializable
{
public function __construct(
public string $type,
public mixed $value = null,
) {}
public static function fromArray(array $data): self
{
return new self(
type: strtolower((string) data_get($data, 'type', 'match')),
value: data_get($data, 'value'),
);
}
public function toArray(): array
{
return [
'type' => $this->type,
'value' => $this->value,
];
}
public function jsonSerialize(): array
{
return $this->toArray();
}
}