From cdcfbb25adcf17078f5fc54d968f960474242a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 26 Oct 2024 16:56:00 +0200 Subject: [PATCH] phpcs --- .../transformer/class-my-calendar.php | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index a041374..cee0942 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -1,6 +1,8 @@ wp_object->ID, '_mc_event_id', true ); - $this->mc_event = mc_get_event( $mc_event_id ); - + $mc_event_id = get_post_meta( $this->wp_object->ID, '_mc_event_id', true ); + $this->mc_event = mc_get_event( $mc_event_id ); $this->mc_event_schema = mc_event_schema( $this->mc_event ); } - /** - * Formats time from the plugin to the activitypub standard + * Formats time from the plugin to the activitypub standard. + * + * @param string $date_string The plugins string representation for a date without time. + * @param string $time_string The plugins string representation for a time. + * + * @return string */ private function convert_time( $date_string, $time_string ): string { // Create a DateTime object with the given date, time, and timezone. @@ -70,6 +77,8 @@ final class My_Calendar extends Event_Transformer { } /** * Get the start time from the events metadata. + * + * @return string The events start date-time. */ public function get_start_time(): string { return $this->convert_time( $this->mc_event->event_begin, $this->mc_event->event_time); @@ -77,6 +86,8 @@ final class My_Calendar extends Event_Transformer { /** * Get the end time from the events metadata. + * + * @return string The events start end-time. */ public function get_end_time(): ?string { return $this->convert_time( $this->mc_event->event_end, $this->mc_event->event_endtime); @@ -88,7 +99,7 @@ final class My_Calendar extends Event_Transformer { * @return Place|null The place/venue if one is set. */ public function get_location(): ?Place { - if ( array_key_exists('location', $this->mc_event_schema ) && $this->mc_event_schema['location']['@type'] == 'Place' ) { + if ( array_key_exists( 'location', $this->mc_event_schema, true ) && 'Place' === $this->mc_event_schema['location']['@type'] ) { $mc_place = $this->mc_event_schema['location']; $place = new Place(); @@ -111,13 +122,6 @@ final class My_Calendar extends Event_Transformer { * @return string status of the event */ public function get_status(): ?string { - return 'CONFIRMED'; # my-calender doesn't implement canceled events. - } - - - public function to_object(): Event { - $activitypub_object = parent::to_object(); - - return $activitypub_object; + return 'CONFIRMED'; // My Calendar doesn't implement canceled events. } }