Passed
Push — master ( 72070c...1d1702 )
by Vinicius Lourenço
03:38
created
Scheduler/Migrations/2018_08_12_000000_create_schedule_status_table.php.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
      *
21 21
      * @return void
22 22
      */
23
-    public function up()
23
+    public function up ()
24 24
     {
25
-        Schema::create(Config::get('scheduler.schedule_status_table'), function (Blueprint $table) {
25
+        Schema::create(Config::get('scheduler.schedule_status_table'), function(Blueprint $table) {
26 26
             $table->increments('id');
27 27
             $table->string('name')->unique();
28 28
             $table->text('description')->nullable();
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return void
38 38
      */
39
-    public function down()
39
+    public function down ()
40 40
     {
41 41
         Schema::drop(Config::get('scheduler.schedule_status_table'));
42 42
     }
Please login to merge, or discard this patch.
src/Scheduler/Migrations/2018_08_12_000000_create_schedules_table.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
      *
21 21
      * @return void
22 22
      */
23
-    public function up()
23
+    public function up ()
24 24
     {
25
-        Schema::create(Config::get('scheduler.schedules_table'), function (Blueprint $table) {
25
+        Schema::create(Config::get('scheduler.schedules_table'), function(Blueprint $table) {
26 26
             $table->increments('id');
27 27
             $table->string('model_type');
28 28
             $table->integer('model_id');
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      *
40 40
      * @return void
41 41
      */
42
-    public function down()
42
+    public function down ()
43 43
     {
44 44
         Schema::drop(Config::get('scheduler.schedules_table'));
45 45
     }
Please login to merge, or discard this patch.
src/Scheduler/SchedulerServiceProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
      *
18 18
      * @return void
19 19
      */
20
-    public function boot()
20
+    public function boot ()
21 21
     {
22 22
         $this->publishes([
23
-            __DIR__.'/../config/config.php' => config_path('scheduler.php'),
23
+            __DIR__ . '/../config/config.php' => config_path('scheduler.php'),
24 24
         ]);
25 25
 
26
-        $this->loadMigrationsFrom(__DIR__.'/Migrations');
27
-        $this->loadTranslationsFrom(__DIR__.'/Translations', 'scheduler');
26
+        $this->loadMigrationsFrom(__DIR__ . '/Migrations');
27
+        $this->loadTranslationsFrom(__DIR__ . '/Translations', 'scheduler');
28 28
 
29 29
         $this->publishes([
30
-            __DIR__.'/Translations' => resource_path('lang/vendor/scheduler'),
30
+            __DIR__ . '/Translations' => resource_path('lang/vendor/scheduler'),
31 31
         ]);
32 32
     }
33 33
 
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return void
38 38
      */
39
-    public function register()
39
+    public function register ()
40 40
     {
41
-        $this->app->singleton(Scheduler::class, function ($app) {
41
+        $this->app->singleton(Scheduler::class, function($app) {
42 42
             return new Scheduler($app);
43 43
         });
44 44
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return void
54 54
      */
55
-    private function mergeConfig()
55
+    private function mergeConfig ()
56 56
     {
57 57
         $this->mergeConfigFrom(
58
-            __DIR__.'/../config/config.php', 'scheduler'
58
+            __DIR__ . '/../config/config.php', 'scheduler'
59 59
         );
60 60
     }
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
src/Scheduler/Contracts/SchedulerModelTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,21 +19,21 @@  discard block
 block discarded – undo
19 19
      * @param  string  $relation
20 20
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
21 21
      */
22
-	abstract public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null);
22
+	abstract public function belongsTo ($related, $foreignKey = null, $ownerKey = null, $relation = null);
23 23
 
24 24
 	/**
25 25
      * Get the value of the model's primary key.
26 26
      *
27 27
      * @return mixed
28 28
      */
29
-	abstract public function getKey();
29
+	abstract public function getKey ();
30 30
 
31 31
 	/**
32 32
      * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait].
33 33
      *
34 34
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
35 35
      */
36
-	public function schedules();
36
+	public function schedules ();
37 37
 
38 38
 	/**
39 39
 	 * Agenda um horário para esta model.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @throws \H4ad\Scheduler\Exceptions\CantAddWithSameStartAt
49 49
 	 * @throws \H4ad\Scheduler\Exceptions\EndCantBeforeStart
50 50
 	 */
51
-	public function addSchedule($start_at, $end_at = null, $status = null);
51
+	public function addSchedule ($start_at, $end_at = null, $status = null);
52 52
 
53 53
 	/**
54 54
 	 * Exibe uma lista dos horários do dia de hoje.
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 *                          que precisem ter uma certa duração.
58 58
 	 * @return array
59 59
 	 */
60
-	public function availableToday($duration = 0);
60
+	public function availableToday ($duration = 0);
61 61
 
62 62
 	/**
63 63
 	 * Lista os horários livres em um determinado dia.
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 *                          que precisem ter uma certa duração.
68 68
 	 * @return array
69 69
 	 */
70
-	public function availableOn($date, $duration = 0);
70
+	public function availableOn ($date, $duration = 0);
71 71
 
72 72
 	/**
73 73
 	 * Remove um horário agendado pelo seu ID ou pelo horário em que foi marcado.
@@ -81,5 +81,5 @@  discard block
 block discarded – undo
81 81
 	 * @throws \H4ad\Scheduler\Exceptions\CantRemoveByDate
82 82
 	 * @throws \H4ad\Scheduler\Exceptions\ModelNotFound
83 83
 	 */
84
-	public function removeSchedule($schedule);
84
+	public function removeSchedule ($schedule);
85 85
 }
86 86
\ No newline at end of file
Please login to merge, or discard this patch.
src/Scheduler/Models/Schedule.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      *
40 40
      * @param int|string $status Pode ser passado o ID do status ou seu nome para seta-lo no horário.
41 41
      */
42
-    public function setStatus($name)
42
+    public function setStatus ($name)
43 43
     {
44 44
     	$this->fill($this->parseStatusKey($name))->save();
45 45
     }
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
      * @param  int|string $key ID ou o nome do status.
51 51
      * @return array
52 52
      */
53
-    public function parseStatusKey($key)
53
+    public function parseStatusKey ($key)
54 54
     {
55
-    	if(is_int($key))
56
-    		return ['status' => $key];
55
+    	if (is_int($key))
56
+    		return [ 'status' => $key ];
57 57
 
58 58
     	$status = ScheduleStatus::where('name', $key)->first();
59 59
 
60
-    	if(is_null($status))
60
+    	if (is_null($status))
61 61
     		throw (new ModelNotFound)->setValues(ScheduleStatus::class);
62 62
 
63
-    	return ['status' => $status->id];
63
+    	return [ 'status' => $status->id ];
64 64
     }
65 65
 
66 66
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param mixed $start_at
71 71
      * @return \Illuminate\Database\Eloquent\Builder
72 72
      */
73
-    public function scopeByStartAt($query, $start_at)
73
+    public function scopeByStartAt ($query, $start_at)
74 74
     {
75 75
         return $query->where('start_at', $start_at);
76 76
     }
Please login to merge, or discard this patch.
src/Scheduler/Models/ScheduleStatus.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
     /**
38 38
      * Construtor para inicilizar a váriavel table.
39 39
      */
40
-    public function __construct(array $attributes = [])
40
+    public function __construct (array $attributes = [ ])
41 41
     {
42 42
         parent::__construct($attributes);
43 43
 
Please login to merge, or discard this patch.
src/Scheduler/Facades/Scheduler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      *
25 25
      * @return string
26 26
      */
27
-    protected static function getFacadeAccessor()
27
+    protected static function getFacadeAccessor ()
28 28
     {
29 29
         return 'scheduler';
30 30
     }
Please login to merge, or discard this patch.
src/Scheduler/Exceptions/CustomException.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @param mixed $model
66 66
      */
67
-    public function __construct($model = 'foo')
67
+    public function __construct ($model = 'foo')
68 68
     {
69 69
         $this->model = $model;
70 70
     }
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @return \Illuminate\Http\JsonResponse
76 76
      */
77
-    public function render()
77
+    public function render ()
78 78
     {
79 79
         return response()->
80 80
             /** @scrutinizer ignore-call */
81 81
             json([
82
-            'messages' => trans('scheduler::exceptions.'. $this->trans, $this->parseValues())
82
+            'messages' => trans('scheduler::exceptions.' . $this->trans, $this->parseValues())
83 83
         ], $this->statusCode);
84 84
     }
85 85
 
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @return array
90 90
      */
91
-    protected function parseValues()
91
+    protected function parseValues ()
92 92
     {
93
-        if(is_array($this->attributes) && is_array($this->values))
93
+        if (is_array($this->attributes) && is_array($this->values))
94 94
             return collect($this->attributes)->combine($this->values)->all();
95 95
 
96 96
         return [ $this->attributes => $this->values ?? $this->isLower() ];
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      *
102 102
      * @return string
103 103
      */
104
-    protected function isLower()
104
+    protected function isLower ()
105 105
     {
106 106
         return $this->lowercase ? strtolower($this->getAlias()) : $this->getAlias();
107 107
     }
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @return string
113 113
      */
114
-    protected function getAlias()
114
+    protected function getAlias ()
115 115
     {
116
-        if(is_object($this->model))
116
+        if (is_object($this->model))
117 117
             $this->model = get_class($this->model);
118 118
 
119
-        return collect(trans('scheduler::exceptions.aliases.'. $this->aliastype))->search($this->model) ?: 'Recurso';
119
+        return collect(trans('scheduler::exceptions.aliases.' . $this->aliastype))->search($this->model) ?: 'Recurso';
120 120
     }
121 121
 
122 122
     /**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      *
125 125
      * @param mixed $values
126 126
      */
127
-    public function setValues($values)
127
+    public function setValues ($values)
128 128
     {
129 129
         $this->values = $values;
130 130
 
Please login to merge, or discard this patch.
src/Scheduler/Scheduler.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @return void
30 30
      */
31
-    public function __construct($app)
31
+    public function __construct ($app)
32 32
     {
33 33
         $this->app = $app;
34 34
     }
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
      * @param string|\Carbon\Carbon $end_at
41 41
      * @return bool
42 42
      */
43
-    public function hasScheduleBetween($model_type, $start_at, $end_at)
43
+    public function hasScheduleBetween ($model_type, $start_at, $end_at)
44 44
     {
45
-        if(!Config::get('scheduler.enable_schedule_conflict'))
45
+        if (!Config::get('scheduler.enable_schedule_conflict'))
46 46
             return false;
47 47
 
48 48
         return !is_null(
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      *                          que precisem ter uma certa duração.
63 63
      * @return array
64 64
      */
65
-    public function availableToday($model_type, $duration)
65
+    public function availableToday ($model_type, $duration)
66 66
     {
67 67
         return $this->availableOn($model_type, Carbon::now(), $duration);
68 68
     }
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
      *                          que precisem ter uma certa duração.
77 77
      * @return array
78 78
      */
79
-    public function availableOn($model_type, $today, $durationMinutes)
79
+    public function availableOn ($model_type, $today, $durationMinutes)
80 80
     {
81 81
         $openingTime = Carbon::parse(Config::get('scheduler.opening_time'))->setDateFrom($today);
82 82
         $closingTime = Carbon::parse(Config::get('scheduler.closing_time'))->setDateFrom($today);
83 83
 
84
-        $livres = [];
84
+        $livres = [ ];
85 85
         $today = Carbon::parse($today->toDateString());
86
-        while($openingTime <= $closingTime)
86
+        while ($openingTime <= $closingTime)
87 87
         {
88 88
             $add = true;
89 89
 
90 90
             foreach (Schedule::orderBy('start_at', 'DESC')->cursor() as $schedule) {
91
-            	if($schedule->model_type != $model_type)
91
+            	if ($schedule->model_type != $model_type)
92 92
             		continue;
93 93
 
94 94
                 $start = Carbon::parse($schedule->start_at);
95 95
                 $begin = Carbon::parse($start->toDateString());
96 96
 
97
-                if($begin->greaterThan($today))
97
+                if ($begin->greaterThan($today))
98 98
                     break;
99 99
 
100
-                if($begin->notEqualTo($today))
100
+                if ($begin->notEqualTo($today))
101 101
                     continue;
102 102
 
103 103
                 $end = Carbon::parse($schedule->end_at);
104
-                if($start <= Carbon::parse($openingTime->toDateTimeString())
104
+                if ($start <= Carbon::parse($openingTime->toDateTimeString())
105 105
                 && $end >= Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes))
106 106
                     $add = false;
107 107
             }
108 108
 
109
-            if($add)
110
-                $livres[] = [
109
+            if ($add)
110
+                $livres[ ] = [
111 111
                     'start_at' => Carbon::parse($openingTime->toDateTimeString()),
112 112
                     'end_at' => Carbon::parse($openingTime->toDateTimeString())->addMinutes($durationMinutes)
113 113
                 ];
Please login to merge, or discard this patch.