mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
35 lines
679 B
PHP
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();
|
|
}
|
|
}
|