From e6c8df62f7ad95f08ac1bfd0a23f6010459ead98 Mon Sep 17 00:00:00 2001 From: Mitul Golakiya Date: Tue, 22 Feb 2022 12:10:42 +0530 Subject: [PATCH] style: Apply fixes from StyleCI (#9) Co-authored-by: StyleCI Bot --- config/laravel-calendar-events.php | 4 +-- src/CalendarEvent.php | 32 +++++++++++++++----- src/CalendarEventRecurrencePattern.php | 7 +++-- src/LaravelCalendarEventsServiceProvider.php | 4 +-- src/RecurringFrequencyType.php | 4 +-- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/config/laravel-calendar-events.php b/config/laravel-calendar-events.php index c4fe583..cf0bb39 100644 --- a/config/laravel-calendar-events.php +++ b/config/laravel-calendar-events.php @@ -6,8 +6,8 @@ return [ /** - * Start Day of the Week + * Start Day of the Week. */ - 'week_starts' => "MO" + 'week_starts' => 'MO', ]; diff --git a/src/CalendarEvent.php b/src/CalendarEvent.php index 6096dcf..0e42a96 100644 --- a/src/CalendarEvent.php +++ b/src/CalendarEvent.php @@ -108,8 +108,9 @@ public function makeRecurring($recurring = true) } /** - * @param Rule $rule + * @param Rule $rule * @param int|null $numberOfOccurrences + * * @return Rule */ private function applyCount(Rule $rule, $numberOfOccurrences = null): Rule @@ -127,6 +128,7 @@ private function applyCount(Rule $rule, $numberOfOccurrences = null): Rule /** * @param Rule $rule + * * @return Rule */ private function applyStartDate(Rule $rule): Rule @@ -139,6 +141,7 @@ private function applyStartDate(Rule $rule): Rule /** * @param Rule $rule + * * @return Rule */ private function applyEndDate(Rule $rule): Rule @@ -153,8 +156,10 @@ private function applyEndDate(Rule $rule): Rule /** * @param Rule $rule - * @return Rule + * * @throws \Recurr\Exception\InvalidRRule + * + * @return Rule */ private function applyRepeatDays(Rule $rule): Rule { @@ -167,6 +172,7 @@ private function applyRepeatDays(Rule $rule): Rule /** * @param Rule $rule + * * @return Rule */ private function applyRepeatMonths(Rule $rule): Rule @@ -180,6 +186,7 @@ private function applyRepeatMonths(Rule $rule): Rule /** * @param Rule $rule + * * @return Rule */ private function applyExcludedDates(Rule $rule): Rule @@ -193,24 +200,29 @@ private function applyExcludedDates(Rule $rule): Rule /** * @param Rule $rule - * @return Rule + * * @throws \Recurr\Exception\InvalidArgument + * + * @return Rule */ private function updateRuleFromConfig(Rule $rule): Rule { $rule->setWeekStart(config('laravel-calendar-events.week_starts')); + return $rule; } /** * @param null $numberOfOccurrences - * @return Recurrence[] + * * @throws \Exception + * + * @return Recurrence[] */ public function getNextOccurrences($numberOfOccurrences = null): array { if (empty($this->end_date) and is_null($numberOfOccurrences) and empty($this->recurring_pattern->max_occurrences)) { - throw new \Exception("Either End Date or Number of Occurrences is required"); + throw new \Exception('Either End Date or Number of Occurrences is required'); } if (!$this->is_recurring or empty($this->recurring_pattern->recurring_type)) { @@ -235,8 +247,10 @@ public function getNextOccurrences($numberOfOccurrences = null): array /** * @param int|null $numberOfEvents - * @return CalendarEvent[] + * * @throws \Exception + * + * @return CalendarEvent[] */ public function getNextEvents($numberOfEvents = null): array { @@ -258,9 +272,11 @@ public function getNextEvents($numberOfEvents = null): array /** * @param Carbon|\DateTime|string $startDate * @param Carbon|\DateTime|string $endDate - * @param int|null $numberOfEvents - * @return CalendarEvent[] + * @param int|null $numberOfEvents + * * @throws \Exception + * + * @return CalendarEvent[] */ public function getEventsBetween($startDate, $endDate, $numberOfEvents = null): array { diff --git a/src/CalendarEventRecurrencePattern.php b/src/CalendarEventRecurrencePattern.php index 657e7f4..c984a8b 100644 --- a/src/CalendarEventRecurrencePattern.php +++ b/src/CalendarEventRecurrencePattern.php @@ -24,12 +24,13 @@ class CalendarEventRecurrencePattern extends BaseDTO /** * @param string $frequency + * * @throws \Exception */ public function setRecurringType(string $frequency) { if (!in_array($frequency, RecurringFrequencyType::$recurringTypes)) { - throw new \Exception("Invalid Frequency"); + throw new \Exception('Invalid Frequency'); } $this->recurring_type = $frequency; @@ -89,11 +90,12 @@ public function setRepeatInterval(int $repeatInterval) /** * @param array $repeatDays + * * @throws \Exception */ public function setRepeatDays(array $repeatDays) { - $validDays = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"]; + $validDays = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']; foreach ($repeatDays as $day) { if (!in_array($day, $validDays)) { @@ -106,6 +108,7 @@ public function setRepeatDays(array $repeatDays) /** * @param array $repeatMonths + * * @throws \Exception */ public function setRepeatMonths(array $repeatMonths) diff --git a/src/LaravelCalendarEventsServiceProvider.php b/src/LaravelCalendarEventsServiceProvider.php index f868848..dd5f754 100644 --- a/src/LaravelCalendarEventsServiceProvider.php +++ b/src/LaravelCalendarEventsServiceProvider.php @@ -21,7 +21,7 @@ public function boot() if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__ . '/../config/laravel-calendar-events.php' => config_path('laravel-calendar-events.php'), + __DIR__.'/../config/laravel-calendar-events.php' => config_path('laravel-calendar-events.php'), ], 'config'); // Publishing the views. @@ -50,7 +50,7 @@ public function boot() public function register() { // Automatically apply the package configuration - $this->mergeConfigFrom(__DIR__ . '/../config/laravel-calendar-events.php', 'laravel-calendar-events'); + $this->mergeConfigFrom(__DIR__.'/../config/laravel-calendar-events.php', 'laravel-calendar-events'); // Register the main class to use with the facade $this->app->singleton('laravel-calendar-events', function () { diff --git a/src/RecurringFrequencyType.php b/src/RecurringFrequencyType.php index b8e2266..ff95a1d 100644 --- a/src/RecurringFrequencyType.php +++ b/src/RecurringFrequencyType.php @@ -1,9 +1,7 @@