Test Failed
Push — develop ( 70abbc...8213ee )
by nguereza
02:59
created
src/Task/Scheduler.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -150,8 +150,8 @@
 block discarded – undo
150 150
             $task->run();
151 151
         } catch (Throwable $e) {
152 152
             $this->logger->error('Error occurred when execute task {task}, error: {error}', [
153
-               'task' => $task->name(),
154
-               'error' => $e->getMessage()
153
+                'task' => $task->name(),
154
+                'error' => $e->getMessage()
155 155
             ]);
156 156
         }
157 157
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
  * @class Scheduler
57 57
  * @package Platine\Framework\Task
58 58
  */
59
-class Scheduler implements SchedulerInterface
60
-{
59
+class Scheduler implements SchedulerInterface {
61 60
     /**
62 61
      * The logger instance
63 62
      * @var LoggerInterface
@@ -76,7 +75,7 @@  discard block
 block discarded – undo
76 75
      */
77 76
     public function __construct(
78 77
         LoggerInterface $logger
79
-    ) {
78
+    ) {
80 79
         $this->logger = $logger;
81 80
     }
82 81
 
@@ -87,8 +86,8 @@  discard block
 block discarded – undo
87 86
     {
88 87
         $datetime = new DateTime();
89 88
         $tasks = $this->tasks;
90
-        foreach ($tasks as $task) {
91
-            if ($this->isDue($task, $datetime)) {
89
+        foreach ($tasks as $task) {
90
+            if ($this->isDue($task, $datetime)) {
92 91
                 $this->execute($task);
93 92
             }
94 93
         }
@@ -100,7 +99,7 @@  discard block
 block discarded – undo
100 99
     public function add(TaskInterface $task): void
101 100
     {
102 101
         $key = $task->name();
103
-        if (array_key_exists($key, $this->tasks)) {
102
+        if (array_key_exists($key, $this->tasks)) {
104 103
             throw new RuntimeException(sprintf('Task [%s] already exist', $key));
105 104
         }
106 105
         $this->tasks[$key] = $task;
@@ -146,9 +145,9 @@  discard block
 block discarded – undo
146 145
     public function execute(TaskInterface $task): void
147 146
     {
148 147
         $this->logger->info('Execute task {task}', ['task' => $task->name()]);
149
-        try {
148
+        try {
150 149
             $task->run();
151
-        } catch (Throwable $e) {
150
+        } catch (Throwable $e) {
152 151
             $this->logger->error('Error occurred when execute task {task}, error: {error}', [
153 152
                'task' => $task->name(),
154 153
                'error' => $e->getMessage()
Please login to merge, or discard this patch.
src/Task/SchedulerInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@
 block discarded – undo
51 51
  * @class SchedulerInterface
52 52
  * @package Platine\Framework\Task
53 53
  */
54
-interface SchedulerInterface
55
-{
54
+interface SchedulerInterface {
56 55
     /**
57 56
      * Execute the scheduler
58 57
      * @return void
Please login to merge, or discard this patch.
src/Task/Command/SchedulerRunCommand.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
         parent::__construct($scheduler, $application, $config);
74 74
 
75 75
         $this->setName('scheduler:run')
76
-             ->setDescription('Execute the scheduled tasks');
76
+                ->setDescription('Execute the scheduled tasks');
77 77
 
78 78
         $this->addArgument('name', 'the name of task to execute instead of all', null, false, true);
79 79
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -57,8 +57,7 @@  discard block
 block discarded – undo
57 57
  * @template T
58 58
  * @extends AbstractCommand<T>
59 59
  */
60
-class SchedulerRunCommand extends AbstractCommand
61
-{
60
+class SchedulerRunCommand extends AbstractCommand {
62 61
     /**
63 62
      * Create new instance
64 63
      * @param SchedulerInterface $scheduler
@@ -69,7 +68,7 @@  discard block
 block discarded – undo
69 68
         SchedulerInterface $scheduler,
70 69
         Application $application,
71 70
         Config $config
72
-    ) {
71
+    ) {
73 72
         parent::__construct($scheduler, $application, $config);
74 73
 
75 74
         $this->setName('scheduler:run')
@@ -81,15 +80,14 @@  discard block
 block discarded – undo
81 80
     /**
82 81
      * {@inheritdoc}
83 82
      */
84
-    public function execute()
85
-    {
83
+    public function execute() {
86 84
         //Load the task
87 85
         $this->loadTasks();
88 86
 
89 87
         $name = $this->getArgumentValue('name');
90
-        if (!empty($name)) {
88
+        if (!empty($name)) {
91 89
             $task = $this->scheduler->get($name);
92
-            if ($task !== null) {
90
+            if ($task !== null) {
93 91
                 $this->scheduler->execute($task);
94 92
                 return;
95 93
             }
Please login to merge, or discard this patch.
src/Task/Command/AbstractCommand.php 1 patch
Braces   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
59 59
  * @package Platine\Framework\Task\Command
60 60
  * @template T
61 61
  */
62
-abstract class AbstractCommand extends Command
63
-{
62
+abstract class AbstractCommand extends Command {
64 63
     /**
65 64
      * The scheduler instance
66 65
      * @var SchedulerInterface
@@ -89,7 +88,7 @@  discard block
 block discarded – undo
89 88
         SchedulerInterface $scheduler,
90 89
         Application $application,
91 90
         Config $config
92
-    ) {
91
+    ) {
93 92
         parent::__construct('scheduler', 'Command to manage scheduler tasks');
94 93
         $this->scheduler = $scheduler;
95 94
         $this->application = $application;
@@ -103,7 +102,7 @@  discard block
 block discarded – undo
103 102
      */
104 103
     protected function addTask($task): void
105 104
     {
106
-        if (is_string($task)) {
105
+        if (is_string($task)) {
107 106
             $task = $this->createTask($task);
108 107
         }
109 108
 
@@ -118,7 +117,7 @@  discard block
 block discarded – undo
118 117
     {
119 118
         /** @var string[] $tasks */
120 119
         $tasks = $this->config->get('tasks', []);
121
-        foreach ($tasks as $task) {
120
+        foreach ($tasks as $task) {
122 121
             $this->addTask($task);
123 122
         }
124 123
     }
@@ -130,11 +129,11 @@  discard block
 block discarded – undo
130 129
      */
131 130
     protected function createTask(string $task): TaskInterface
132 131
     {
133
-        if ($this->application->has($task)) {
132
+        if ($this->application->has($task)) {
134 133
             return $this->application->get($task);
135 134
         }
136 135
 
137
-        if (class_exists($task)) {
136
+        if (class_exists($task)) {
138 137
             /** @var TaskInterface $o */
139 138
             $o = new $task();
140 139
             return $o;
@@ -157,7 +156,7 @@  discard block
 block discarded – undo
157 156
         //Load providers tasks
158 157
         /** @var class-string[] $tasks */
159 158
         $tasks = $this->application->getProvidersTasks();
160
-        foreach ($tasks as $task) {
159
+        foreach ($tasks as $task) {
161 160
             $this->addTask($task);
162 161
         }
163 162
     }
Please login to merge, or discard this patch.
src/Task/Command/SchedulerListCommand.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
         parent::__construct($scheduler, $application, $config);
76 76
 
77 77
         $this->setName('scheduler:list')
78
-             ->setDescription('Show the list of scheduled tasks');
78
+                ->setDescription('Show the list of scheduled tasks');
79 79
     }
80 80
 
81 81
     /**
Please login to merge, or discard this patch.
Braces   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
59 59
  * @template T
60 60
  * @extends AbstractCommand<T>
61 61
  */
62
-class SchedulerListCommand extends AbstractCommand
63
-{
62
+class SchedulerListCommand extends AbstractCommand {
64 63
     /**
65 64
      * Create new instance
66 65
      * @param SchedulerInterface $scheduler
@@ -71,7 +70,7 @@  discard block
 block discarded – undo
71 70
         SchedulerInterface $scheduler,
72 71
         Application $application,
73 72
         Config $config
74
-    ) {
73
+    ) {
75 74
         parent::__construct($scheduler, $application, $config);
76 75
 
77 76
         $this->setName('scheduler:list')
@@ -81,8 +80,7 @@  discard block
 block discarded – undo
81 80
     /**
82 81
      * {@inheritdoc}
83 82
      */
84
-    public function execute()
85
-    {
83
+    public function execute() {
86 84
         //Load the task list
87 85
         $this->loadTasks();
88 86
 
@@ -102,7 +100,7 @@  discard block
 block discarded – undo
102 100
         $tasks = $this->scheduler->all();
103 101
 
104 102
         $rows = [];
105
-        foreach ($tasks as $task) {
103
+        foreach ($tasks as $task) {
106 104
             $nextExecution = date('Y-m-d H:i', Cron::parse($task->expression()));
107 105
             $rows[] = [
108 106
                 'name' => $task->name(),
Please login to merge, or discard this patch.
src/Task/TaskInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@
 block discarded – undo
51 51
  * @class TaskInterface
52 52
  * @package Platine\Framework\Task
53 53
  */
54
-interface TaskInterface
55
-{
54
+interface TaskInterface {
56 55
     /**
57 56
      * Execute the task
58 57
      * @return void
Please login to merge, or discard this patch.
src/Task/Cron.php 1 patch
Braces   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -53,8 +53,7 @@  discard block
 block discarded – undo
53 53
  * @class Cron
54 54
  * @package Platine\Framework\Task
55 55
  */
56
-class Cron
57
-{
56
+class Cron {
58 57
     /**
59 58
      * Parse the given cron expression and finds next execution time(stamp)
60 59
      * @param string $expression
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
                 . '((\*(\/[0-9]+)?)|[0-9\-\,\/]+)\s+'
81 80
                 . '((\*(\/[0-9]+)?)|[0-9\-\,\/]+)\s+'
82 81
                 . '((\*(\/[0-9]+)?)|[0-9\-\,\/]+)$/i';
83
-        if (!preg_match($cronRegex, $cronExpression)) {
82
+        if (!preg_match($cronRegex, $cronExpression)) {
84 83
             throw new InvalidArgumentException(sprintf(
85 84
                 'Invalid cron expression [%s]',
86 85
                 $expression
@@ -88,12 +87,12 @@  discard block
 block discarded – undo
88 87
         }
89 88
 
90 89
         $crons = preg_split('/[\s]+/i', $cronExpression);
91
-        if ($crons === false) {
90
+        if ($crons === false) {
92 91
             return 0;
93 92
         }
94 93
 
95 94
         $start = time();
96
-        if ($timestamp !== null) {
95
+        if ($timestamp !== null) {
97 96
             $start = $timestamp;
98 97
         }
99 98
 
@@ -109,7 +108,7 @@  discard block
 block discarded – undo
109 108
         // to check more than 1 year ahead
110 109
         $total = 60 * 60 * 24 * 366;
111 110
 
112
-        for ($i = 0; $i <= $total; $i += 60) {
111
+        for ($i = 0; $i <= $total; $i += 60) {
113 112
             $current = $start + $i;
114 113
             if (
115 114
                 in_array((int) date('j', $current), $dates['dom']) &&
@@ -117,7 +116,7 @@  discard block
 block discarded – undo
117 116
                 in_array((int) date('w', $current), $dates['dow']) &&
118 117
                 in_array((int) date('G', $current), $dates['hours']) &&
119 118
                 in_array((int) date('i', $current), $dates['minutes'])
120
-            ) {
119
+            ) {
121 120
                 return $current;
122 121
             }
123 122
         }
@@ -137,7 +136,7 @@  discard block
 block discarded – undo
137 136
     {
138 137
         $result = [];
139 138
         $values = explode(',', $expression);
140
-        foreach ($values as $value) {
139
+        foreach ($values as $value) {
141 140
             $slashValues = explode('/', $value);
142 141
             $step = $slashValues[1] ?? 1;
143 142
             $minusValues = explode('-', $slashValues[0]);
@@ -147,7 +146,7 @@  discard block
 block discarded – undo
147 146
             $maximum = count($minusValues) === 2 ? $minusValues[1]
148 147
                         : ($slashValues[0] === '*' ? $max : $slashValues[0]);
149 148
 
150
-            for ($i = $minimum; $i <= $maximum; $i += $step) {
149
+            for ($i = $minimum; $i <= $maximum; $i += $step) {
151 150
                 $result[$i] = intval($i);
152 151
             }
153 152
         }
Please login to merge, or discard this patch.
src/Service/Provider/FilesystemServiceProvider.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@
 block discarded – undo
56 56
  * @class FilesystemServiceProvider
57 57
  * @package Platine\Framework\Service\Provider
58 58
  */
59
-class FilesystemServiceProvider extends ServiceProvider
60
-{
59
+class FilesystemServiceProvider extends ServiceProvider {
61 60
     /**
62 61
      * {@inheritdoc}
63 62
      */
Please login to merge, or discard this patch.
src/Service/Provider/AuditServiceProvider.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@
 block discarded – undo
56 56
  * @class AuditServiceProvider
57 57
  * @package Platine\Framework\Service\Provider
58 58
  */
59
-class AuditServiceProvider extends ServiceProvider
60
-{
59
+class AuditServiceProvider extends ServiceProvider {
61 60
     /**
62 61
      * {@inheritdoc}
63 62
      */
Please login to merge, or discard this patch.