| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry; |
| 5 |
|
| 6 |
final class MonitorSchedule |
| 7 |
{ |
| 8 |
/** |
| 9 |
* @var string The type of the schedule |
| 10 |
*/ |
| 11 |
private $type; |
| 12 |
/** |
| 13 |
* @var string|int The value of the schedule |
| 14 |
*/ |
| 15 |
private $value; |
| 16 |
/** |
| 17 |
* @var MonitorScheduleUnit|null The unit of the schedule |
| 18 |
*/ |
| 19 |
private $unit; |
| 20 |
public const TYPE_CRONTAB = 'crontab'; |
| 21 |
public const TYPE_INTERVAL = 'interval'; |
| 22 |
/** |
| 23 |
* @param string $type The type of the schedule |
| 24 |
* @param string|int $value The value of the schedule |
| 25 |
* @param MonitorScheduleUnit|null $unit The unit of the schedule |
| 26 |
*/ |
| 27 |
public function __construct(string $type, $value, ?MonitorScheduleUnit $unit = null) |
| 28 |
{ |
| 29 |
$this->type = $type; |
| 30 |
$this->value = $value; |
| 31 |
$this->unit = $unit; |
| 32 |
} |
| 33 |
public static function crontab(string $value) : self |
| 34 |
{ |
| 35 |
return new self(self::TYPE_CRONTAB, $value); |
| 36 |
} |
| 37 |
public static function interval(int $value, MonitorScheduleUnit $unit) : self |
| 38 |
{ |
| 39 |
return new self(self::TYPE_INTERVAL, $value, $unit); |
| 40 |
} |
| 41 |
public function getType() : string |
| 42 |
{ |
| 43 |
return $this->type; |
| 44 |
} |
| 45 |
public function setType(string $type) : self |
| 46 |
{ |
| 47 |
$this->type = $type; |
| 48 |
return $this; |
| 49 |
} |
| 50 |
/** |
| 51 |
* @return string|int |
| 52 |
*/ |
| 53 |
public function getValue() |
| 54 |
{ |
| 55 |
return $this->value; |
| 56 |
} |
| 57 |
/** |
| 58 |
* @param string|int $value |
| 59 |
*/ |
| 60 |
public function setValue($value) : self |
| 61 |
{ |
| 62 |
$this->value = $value; |
| 63 |
return $this; |
| 64 |
} |
| 65 |
public function getUnit() : ?MonitorScheduleUnit |
| 66 |
{ |
| 67 |
return $this->unit; |
| 68 |
} |
| 69 |
public function setUnit(?MonitorScheduleUnit $unit) : self |
| 70 |
{ |
| 71 |
$this->unit = $unit; |
| 72 |
return $this; |
| 73 |
} |
| 74 |
/** |
| 75 |
* @return array<string, string|int> |
| 76 |
*/ |
| 77 |
public function toArray() : array |
| 78 |
{ |
| 79 |
return ['type' => $this->type, 'value' => $this->value, 'unit' => (string) $this->unit]; |
| 80 |
} |
| 81 |
} |
| 82 |
|