Skip to content

Commit

Permalink
style: Apply fixes from StyleCI (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: StyleCI Bot <bot@styleci.io>
  • Loading branch information
mitulgolakiya and StyleCIBot authored Feb 22, 2022
1 parent 741f33f commit e6c8df6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
4 changes: 2 additions & 2 deletions config/laravel-calendar-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
return [

/**
* Start Day of the Week
* Start Day of the Week.
*/
'week_starts' => "MO"
'week_starts' => 'MO',

];
32 changes: 24 additions & 8 deletions src/CalendarEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -127,6 +128,7 @@ private function applyCount(Rule $rule, $numberOfOccurrences = null): Rule

/**
* @param Rule $rule
*
* @return Rule
*/
private function applyStartDate(Rule $rule): Rule
Expand All @@ -139,6 +141,7 @@ private function applyStartDate(Rule $rule): Rule

/**
* @param Rule $rule
*
* @return Rule
*/
private function applyEndDate(Rule $rule): Rule
Expand All @@ -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
{
Expand All @@ -167,6 +172,7 @@ private function applyRepeatDays(Rule $rule): Rule

/**
* @param Rule $rule
*
* @return Rule
*/
private function applyRepeatMonths(Rule $rule): Rule
Expand All @@ -180,6 +186,7 @@ private function applyRepeatMonths(Rule $rule): Rule

/**
* @param Rule $rule
*
* @return Rule
*/
private function applyExcludedDates(Rule $rule): Rule
Expand All @@ -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)) {
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down
7 changes: 5 additions & 2 deletions src/CalendarEventRecurrencePattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand All @@ -106,6 +108,7 @@ public function setRepeatDays(array $repeatDays)

/**
* @param array $repeatMonths
*
* @throws \Exception
*/
public function setRepeatMonths(array $repeatMonths)
Expand Down
4 changes: 2 additions & 2 deletions src/LaravelCalendarEventsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 () {
Expand Down
4 changes: 1 addition & 3 deletions src/RecurringFrequencyType.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?php


namespace InfyOm\LaravelCalendarEvents;


class RecurringFrequencyType
{
const RECURRING_TYPE_DAILY = 'DAILY';
const RECURRING_TYPE_WEEKLY = 'WEEKLY';
const RECURRING_TYPE_MONTHLY = 'MONTHLY';
const RECURRING_TYPE_YEARLY = 'YEARLY';

static $recurringTypes = [
public static $recurringTypes = [
self::RECURRING_TYPE_DAILY,
self::RECURRING_TYPE_WEEKLY,
self::RECURRING_TYPE_MONTHLY,
Expand Down

0 comments on commit e6c8df6

Please sign in to comment.