10 private const TRIGGER_START =
'trigger_start';
11 private const TRIGGER_END =
'trigger_end';
12 private const TRIGGER_DATE =
'trigger_date';
14 private $triggerInterval;
15 private $triggerMode = self::TRIGGER_DATE;
18 public static function date(
Date $date,
string $description =
null):
Alert
20 return static::getInstance($description)->
triggerDate($date);
25 $interval = new \DateInterval(
"PT{$minutes}M");
26 $interval->invert = 1;
28 return static::getInstance($description)->triggerAtStart($interval);
33 return static::getInstance($description)->
triggerAtStart(
new \DateInterval(
"PT{$min}M"));
38 $interval = new \DateInterval(
"PT{$min}M");
39 $interval->invert = 1;
41 return static::getInstance($description)->triggerAtEnd($interval);
46 return static::getInstance($description)->
triggerAtEnd(
new \DateInterval(
"PT{$min}M"));
49 private static function getInstance(array $reminds = [], $description =
''):
Alert
51 return new self($reminds, $description);
54 public function __construct(array $reminds = [], $description =
'')
83 $this->triggerMode = self::TRIGGER_DATE;
91 $this->triggerMode = self::TRIGGER_START;
92 $this->triggerInterval = $interval;
99 $this->triggerMode = self::TRIGGER_END;
100 $this->triggerInterval = $interval;
107 return Content::getInstance($this->
getType())
109 ->textProperty(
'DESCRIPTION', $this->
message)
110 ->property($this->resolveTriggerProperty());
113 private function resolveTriggerProperty()
115 if ($this->triggerMode === self::TRIGGER_DATE) {
116 return DateTimePropertyType::getInstance(
120 )->addParameter(
new Parameter(
'VALUE',
'DATE-TIME'));
125 if ($this->triggerMode === self::TRIGGER_END) {
126 return $property->addParameter(
new Parameter(
'RELATED',
'END'));
textProperty($names, ?string $value, bool $disableEscaping=false)