Skip to content
This repository was archived by the owner on Jan 17, 2020. It is now read-only.

Commit 938b3a3

Browse files
committed
Added comments for methods. [skip ci]
1 parent b8158c5 commit 938b3a3

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

Diff for: src/TimeRange.php

+32
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ class TimeRange
99
protected $timeRangeString;
1010
protected $carbonInstance = Carbon::class;
1111

12+
/**
13+
* Create a new TimeRange instance.
14+
*
15+
* @param string $timeRangeString
16+
* @param Carbon $carbonInstance
17+
* @return void
18+
*/
1219
public function __construct($timeRangeString, $carbonInstance = null)
1320
{
1421
$this->timeRangeString = $timeRangeString;
@@ -20,6 +27,8 @@ public function __construct($timeRangeString, $carbonInstance = null)
2027

2128
/**
2229
* Check if the string provided is a TimeRange formatted string.
30+
*
31+
* @return bool
2332
*/
2433
public function isValidTimeRange()
2534
{
@@ -28,6 +37,8 @@ public function isValidTimeRange()
2837

2938
/**
3039
* Check if the string provided is a valid hour:minute formatted string.
40+
*
41+
* @return bool
3142
*/
3243
public function isValidHourMinute($hourMinute)
3344
{
@@ -36,6 +47,9 @@ public function isValidHourMinute($hourMinute)
3647

3748
/**
3849
* Check if a specific hour:minute is in the timerange.
50+
*
51+
* @param string $hourMinute The time in format hour:minute
52+
* @return bool
3953
*/
4054
public function isInTimeRange($hourMinute)
4155
{
@@ -54,6 +68,8 @@ public function isInTimeRange($hourMinute)
5468

5569
/**
5670
* Get the start Carbon instance as 1st January 2018, and a specified hour.
71+
*
72+
* @return Carbon
5773
*/
5874
public function getStartCarbonInstance()
5975
{
@@ -62,6 +78,8 @@ public function getStartCarbonInstance()
6278

6379
/**
6480
* Get the end Carbon instance as 1st/2nd January 2018, at the right hour and minute.
81+
*
82+
* @return Carbon
6583
*/
6684
public function getEndCarbonInstance()
6785
{
@@ -70,6 +88,8 @@ public function getEndCarbonInstance()
7088

7189
/**
7290
* Difference in hours between the both ends.
91+
*
92+
* @return int The difference, in hours.
7393
*/
7494
public function diffInHours()
7595
{
@@ -82,6 +102,8 @@ public function diffInHours()
82102

83103
/**
84104
* Difference in minutes between the both ends.
105+
*
106+
* @return int The difference, in minutes.
85107
*/
86108
public function diffInMinutes()
87109
{
@@ -94,6 +116,8 @@ public function diffInMinutes()
94116

95117
/**
96118
* Get the hour of the starting part.
119+
*
120+
* @return int
97121
*/
98122
public function getStartHour()
99123
{
@@ -106,6 +130,8 @@ public function getStartHour()
106130

107131
/**
108132
* Get the minute of the starting part.
133+
*
134+
* @return int
109135
*/
110136
public function getStartMinute()
111137
{
@@ -118,6 +144,8 @@ public function getStartMinute()
118144

119145
/**
120146
* Get the hour of the ending part.
147+
*
148+
* @return int
121149
*/
122150
public function getEndHour()
123151
{
@@ -130,6 +158,8 @@ public function getEndHour()
130158

131159
/**
132160
* Get the minute of the ending part.
161+
*
162+
* @return int
133163
*/
134164
public function getEndMinute()
135165
{
@@ -144,6 +174,8 @@ public function getEndMinute()
144174
* Get the time range in array format.
145175
* This will return something like ['08:00', '17:00']
146176
* Use get[Start|End][Hour|Minute]() method to get the hours as integers.
177+
*
178+
* @return array
147179
*/
148180
public function toArray()
149181
{

Diff for: src/Traits/HasSchedule.php

+44
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ trait HasSchedule
1616

1717
/**
1818
* Returns a morphOne relationship class of the schedule.
19+
*
20+
* @return morphOne The relatinship.
1921
*/
2022
public function schedule()
2123
{
@@ -24,6 +26,8 @@ public function schedule()
2426

2527
/**
2628
* Get the Schedule array or null if it doesn't have.
29+
*
30+
* @return array|null The array with schedules or null.
2731
*/
2832
public function getSchedule()
2933
{
@@ -32,6 +36,8 @@ public function getSchedule()
3236

3337
/**
3438
* Get the Exclusions array or null if it doesn't have.
39+
*
40+
* @return array The array with exclusions.
3541
*/
3642
public function getExclusions()
3743
{
@@ -40,6 +46,8 @@ public function getExclusions()
4046

4147
/**
4248
* Check if the model has a schedule set.
49+
*
50+
* @return boolean If the binded model has a schedule already set.
4351
*/
4452
public function hasSchedule()
4553
{
@@ -48,6 +56,9 @@ public function hasSchedule()
4856

4957
/**
5058
* Set a new schedule.
59+
*
60+
* @param array $scheduleArray The array with schedules.
61+
* @return array The schedule array.
5162
*/
5263
public function setSchedule(array $scheduleArray = [])
5364
{
@@ -66,6 +77,9 @@ public function setSchedule(array $scheduleArray = [])
6677

6778
/**
6879
* Update the model's schedule.
80+
*
81+
* @param array $scheduleArray The array with schedules that should be replaced.
82+
* @return array The schedule array.
6983
*/
7084
public function updateSchedule(array $scheduleArray)
7185
{
@@ -78,6 +92,9 @@ public function updateSchedule(array $scheduleArray)
7892

7993
/**
8094
* Set exclusions.
95+
*
96+
* @param array $exclusionsArray The array with exclusions.
97+
* @return array The exclusions array.
8198
*/
8299
public function setExclusions(array $exclusionsArray = [])
83100
{
@@ -94,6 +111,9 @@ public function setExclusions(array $exclusionsArray = [])
94111

95112
/**
96113
* Update exclusions (alias for setExclusions).
114+
*
115+
* @param array $exclusionsArray The array with exclusions.
116+
* @return array The exclusions array.
97117
*/
98118
public function updateExclusions(array $exclusionsArray)
99119
{
@@ -102,6 +122,8 @@ public function updateExclusions(array $exclusionsArray)
102122

103123
/**
104124
* Delete the schedule of this model.
125+
*
126+
* @return bool Wether the schedule was deleted or not.
105127
*/
106128
public function deleteSchedule()
107129
{
@@ -110,6 +132,8 @@ public function deleteSchedule()
110132

111133
/**
112134
* Delete the exclusions of this model.
135+
*
136+
* @return bool|array Wether the exclusions were cleared or not.
113137
*/
114138
public function deleteExclusions()
115139
{
@@ -126,6 +150,9 @@ public function deleteExclusions()
126150

127151
/**
128152
* Check if the model is available on a certain day/date.
153+
*
154+
* @param string|Carbon|DateTime $dateOrDay The datetime, date or the day.
155+
* @return bool Wether it is available on that day.
129156
*/
130157
public function isAvailableOn($dateOrDay)
131158
{
@@ -162,6 +189,9 @@ public function isAvailableOn($dateOrDay)
162189

163190
/**
164191
* Check if the model is unavailable on a certain day/date.
192+
*
193+
* @param string|Carbon|DateTime $dateOrDay The datetime, date or the day.
194+
* @return bool Wether it is unavailable on that day.
165195
*/
166196
public function isUnavailableOn($dateOrDay)
167197
{
@@ -170,6 +200,10 @@ public function isUnavailableOn($dateOrDay)
170200

171201
/**
172202
* Check if the model is available on a certain day/date and time.
203+
*
204+
* @param string|Carbon|DateTime $dateOrDay The datetime, date or the day.
205+
* @param string The time.
206+
* @return bool Wether it is available on that day, at a certain time.
173207
*/
174208
public function isAvailableOnAt($dateOrDay, $time)
175209
{
@@ -212,6 +246,10 @@ public function isAvailableOnAt($dateOrDay, $time)
212246

213247
/**
214248
* Check if the model is unavailable on a certain day/date and time.
249+
*
250+
* @param string|Carbon|DateTime $dateOrDay The datetime, date or the day.
251+
* @param string The time.
252+
* @return bool Wether it is unavailable on that day, at a certain time.
215253
*/
216254
public function isUnavailableOnAt($dateOrDay, $time)
217255
{
@@ -220,6 +258,9 @@ public function isUnavailableOnAt($dateOrDay, $time)
220258

221259
/**
222260
* Get the amount of hours on a certain day.
261+
*
262+
* @param string|Carbon|DateTime $dateOrDay The datetime, date or the day.
263+
* @return int The amount of hours on that day.
223264
*/
224265
public function getHoursOn($dateOrDay)
225266
{
@@ -261,6 +302,9 @@ public function getHoursOn($dateOrDay)
261302

262303
/**
263304
* Get the amount of minutes on a certain day.
305+
*
306+
* @param string|Carbon|DateTime $dateOrDay The datetime, date or the day.
307+
* @return int The amount of minutes on that day.
264308
*/
265309
public function getMinutesOn($dateOrDay)
266310
{

0 commit comments

Comments
 (0)