diff --git a/src/Generators/BaseOutlook.php b/src/Generators/BaseOutlook.php index 69f5f2f..48de855 100644 --- a/src/Generators/BaseOutlook.php +++ b/src/Generators/BaseOutlook.php @@ -12,23 +12,23 @@ abstract class BaseOutlook implements Generator { /** @see https://www.php.net/manual/en/function.date.php */ - protected string $dateFormat = 'Y-m-d'; + private const DATE_FORMAT = 'Y-m-d'; /** @see https://www.php.net/manual/en/function.date.php */ - protected string $dateTimeFormat = 'Y-m-d\TH:i:s\Z'; + private const DATETIME_FORMAT = 'Y-m-d\TH:i:s\Z'; /** * Get base URL for links. * @return non-empty-string */ - abstract public function baseUrl(): string; + abstract protected function baseUrl(): string; /** @inheritDoc */ public function generate(Link $link): string { $url = $this->baseUrl(); - $dateTimeFormat = $link->allDay ? $this->dateFormat : $this->dateTimeFormat; + $dateTimeFormat = $link->allDay ? self::DATE_FORMAT : self::DATETIME_FORMAT; $utcStartDateTime = $link->from->setTimezone(new DateTimeZone('UTC')); $utcEndDateTime = $link->to->setTimezone(new DateTimeZone('UTC')); diff --git a/src/Generators/Google.php b/src/Generators/Google.php index 7f716da..f79df36 100644 --- a/src/Generators/Google.php +++ b/src/Generators/Google.php @@ -12,18 +12,22 @@ class Google implements Generator { /** @see https://www.php.net/manual/en/function.date.php */ - protected string $dateFormat = 'Ymd'; + private const DATE_FORMAT = 'Ymd'; - protected string $dateTimeFormat = 'Ymd\THis\Z'; + /** @see https://www.php.net/manual/en/function.date.php */ + private const DATETIME_FORMAT = 'Ymd\THis\Z'; + + /** @var non-empty-string */ + protected const BASE_URL = 'https://calendar.google.com/calendar/render?action=TEMPLATE'; /** @inheritDoc */ public function generate(Link $link): string { - $url = 'https://calendar.google.com/calendar/render?action=TEMPLATE'; + $url = self::BASE_URL; $utcStartDateTime = $link->from->setTimezone(new DateTimeZone('UTC')); $utcEndDateTime = $link->to->setTimezone(new DateTimeZone('UTC')); - $dateTimeFormat = $link->allDay ? $this->dateFormat : $this->dateTimeFormat; + $dateTimeFormat = $link->allDay ? self::DATE_FORMAT : self::DATETIME_FORMAT; $url .= '&dates='.$utcStartDateTime->format($dateTimeFormat).'/'.$utcEndDateTime->format($dateTimeFormat); // Add timezone name if it is specified in both from and to dates and is the same for both diff --git a/src/Generators/WebOffice.php b/src/Generators/WebOffice.php index 1462368..14f8783 100644 --- a/src/Generators/WebOffice.php +++ b/src/Generators/WebOffice.php @@ -2,13 +2,13 @@ namespace Spatie\CalendarLinks\Generators; -class WebOffice extends BaseOutlook +final class WebOffice extends BaseOutlook { /** @var non-empty-string */ - protected const BASE_URL = 'https://outlook.office.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent'; + private const BASE_URL = 'https://outlook.office.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent'; /** @inheritDoc */ - public function baseUrl(): string + protected function baseUrl(): string { return static::BASE_URL; } diff --git a/src/Generators/WebOutlook.php b/src/Generators/WebOutlook.php index 8316dae..c1ebb33 100644 --- a/src/Generators/WebOutlook.php +++ b/src/Generators/WebOutlook.php @@ -2,13 +2,13 @@ namespace Spatie\CalendarLinks\Generators; -class WebOutlook extends BaseOutlook +final class WebOutlook extends BaseOutlook { /** @var non-empty-string */ - protected const BASE_URL = 'https://outlook.live.com/calendar/action/compose?path=/calendar/action/compose&rru=addevent'; + private const BASE_URL = 'https://outlook.live.com/calendar/action/compose?path=/calendar/action/compose&rru=addevent'; /** @inheritDoc */ - public function baseUrl(): string + protected function baseUrl(): string { return static::BASE_URL; } diff --git a/src/Generators/Yahoo.php b/src/Generators/Yahoo.php index e11f041..8531c8c 100644 --- a/src/Generators/Yahoo.php +++ b/src/Generators/Yahoo.php @@ -12,16 +12,20 @@ class Yahoo implements Generator { /** @see https://www.php.net/manual/en/function.date.php */ - protected string $dateFormat = 'Ymd'; + private const DATE_FORMAT = 'Ymd'; - protected string $dateTimeFormat = 'Ymd\THis\Z'; + /** @see https://www.php.net/manual/en/function.date.php */ + private const DATETIME_FORMAT = 'Ymd\THis\Z'; + + /** @var non-empty-string */ + protected const BASE_URL = 'https://calendar.yahoo.com/?v=60&view=d&type=20'; /** @inheritDoc */ public function generate(Link $link): string { - $url = 'https://calendar.yahoo.com/?v=60&view=d&type=20'; + $url = self::BASE_URL; - $dateTimeFormat = $link->allDay ? $this->dateFormat : $this->dateTimeFormat; + $dateTimeFormat = $link->allDay ? self::DATE_FORMAT : self::DATETIME_FORMAT; if ($link->allDay) { $url .= '&ST='.$link->from->format($dateTimeFormat);