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

Commit

Permalink
Apply fixes from StyleCI (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki authored Jun 23, 2018
1 parent ad58db0 commit b8158c5
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 247 deletions.
10 changes: 5 additions & 5 deletions config/schedule.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

return [
/**

/*
* The model the app uses.
* Feel free to change it however you like, but do not
* forget to extend the original model.
*
* Or don't extend it from the original model.
*
* Or don't extend it from the original model.
* I'm just some text. I can't stop you.
*/

'model' => \Rennokki\Schedule\Models\ScheduleModel::class,

];
];
2 changes: 1 addition & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
];
});
});
4 changes: 1 addition & 3 deletions database/migrations/2018_05_19_135648_schedules.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class Schedules extends Migration
*/
public function up()
{
Schema::create('schedules', function(Blueprint $table) {

Schema::create('schedules', function (Blueprint $table) {
$table->increments('id');

$table->integer('model_id');
Expand All @@ -24,7 +23,6 @@ public function up()
$table->text('exclusions')->nullable();

$table->timestamps();

});
}

Expand Down
43 changes: 26 additions & 17 deletions src/TimeRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

use Carbon\Carbon;

class TimeRange {

class TimeRange
{
protected $timeRangeString;
protected $carbonInstance = Carbon::class;

public function __construct($timeRangeString, $carbonInstance = null)
{
$this->timeRangeString = $timeRangeString;
if($carbonInstance)

if ($carbonInstance) {
$this->carbonInstance = $carbonInstance;
}
}

/**
Expand All @@ -38,8 +39,9 @@ public function isValidHourMinute($hourMinute)
*/
public function isInTimeRange($hourMinute)
{
if(!$this->isValidHourMinute($hourMinute))
if (! $this->isValidHourMinute($hourMinute)) {
return false;
}

list($hour, $minute) = explode(':', $hourMinute);
$hour = (int) $hour;
Expand Down Expand Up @@ -71,8 +73,9 @@ public function getEndCarbonInstance()
*/
public function diffInHours()
{
if(!$this->isValidTimeRange())
if (! $this->isValidTimeRange()) {
return 0;
}

return (int) $this->getStartCarbonInstance()->diffInHours($this->getEndCarbonInstance());
}
Expand All @@ -82,8 +85,9 @@ public function diffInHours()
*/
public function diffInMinutes()
{
if(!$this->isValidTimeRange())
if (! $this->isValidTimeRange()) {
return 0;
}

return (int) $this->getStartCarbonInstance()->diffInMinutes($this->getEndCarbonInstance());
}
Expand All @@ -93,8 +97,9 @@ public function diffInMinutes()
*/
public function getStartHour()
{
if(!$this->isValidTimeRange())
return null;
if (! $this->isValidTimeRange()) {
return;
}

return (int) explode(':', $this->toArray()[0])[0];
}
Expand All @@ -104,8 +109,9 @@ public function getStartHour()
*/
public function getStartMinute()
{
if(!$this->isValidTimeRange())
return null;
if (! $this->isValidTimeRange()) {
return;
}

return (int) explode(':', $this->toArray()[0])[1];
}
Expand All @@ -115,8 +121,9 @@ public function getStartMinute()
*/
public function getEndHour()
{
if(!$this->isValidTimeRange())
return null;
if (! $this->isValidTimeRange()) {
return;
}

return (int) explode(':', $this->toArray()[1])[0];
}
Expand All @@ -126,8 +133,9 @@ public function getEndHour()
*/
public function getEndMinute()
{
if(!$this->isValidTimeRange())
return null;
if (! $this->isValidTimeRange()) {
return;
}

return (int) explode(':', $this->toArray()[1])[1];
}
Expand All @@ -139,9 +147,10 @@ public function getEndMinute()
*/
public function toArray()
{
if(!$this->isValidTimeRange())
if (! $this->isValidTimeRange()) {
return [];
}

return (array) explode('-', $this->timeRangeString);
}
}
}
Loading

0 comments on commit b8158c5

Please sign in to comment.