Code Duplication    Length = 18-25 lines in 2 locations

src/Understand/UnderstandLaravel5/UnderstandLaravel5ServiceProvider.php 1 location

@@ 161-185 (lines=25) @@
158
159
        // starting from L5.2 JobProcessing event class was introduced
160
        // https://github.com/illuminate/queue/commit/ce2b5518902b1bcb9ef650c41900fc8c6392eb0c
161
        if ($this->app->runningInConsole())
162
        {
163
            if ($this->detectLaravelVersion(['5.0', '5.1']))
164
            {
165
                $this->app['events']->listen('illuminate.queue.after', function()
166
                {
167
                    $this->app['understand.tokenProvider']->generate();
168
                    $this->app['understand.dataCollector']->reset();
169
                });
170
171
                $this->app['events']->listen('illuminate.queue.failed', function()
172
                {
173
                    $this->app['understand.tokenProvider']->generate();
174
                    $this->app['understand.dataCollector']->reset();
175
                });
176
            }
177
            else
178
            {
179
                $this->app['events']->listen('Illuminate\Queue\Events\JobProcessing', function()
180
                {
181
                    $this->app['understand.tokenProvider']->generate();
182
                    $this->app['understand.dataCollector']->reset();
183
                });
184
            }
185
        }
186
    }
187
188
    /**

src/Understand/UnderstandLaravel5/UnderstandLumenServiceProvider.php 1 location

@@ 176-193 (lines=18) @@
173
174
        // starting from L5.2 JobProcessing event class was introduced
175
        // https://github.com/illuminate/queue/commit/ce2b5518902b1bcb9ef650c41900fc8c6392eb0c
176
        if ($this->app->runningInConsole()) {
177
            if ($this->detectLumenVersion(['5.0', '5.1'])) {
178
                $this->app['events']->listen('illuminate.queue.after', function () {
179
                    $this->app['understand.tokenProvider']->generate();
180
                    $this->app['understand.dataCollector']->reset();
181
                });
182
183
                $this->app['events']->listen('illuminate.queue.failed', function () {
184
                    $this->app['understand.tokenProvider']->generate();
185
                    $this->app['understand.dataCollector']->reset();
186
                });
187
            } else {
188
                $this->app['events']->listen('Illuminate\Queue\Events\JobProcessing', function () {
189
                    $this->app['understand.tokenProvider']->generate();
190
                    $this->app['understand.dataCollector']->reset();
191
                });
192
            }
193
        }
194
    }
195
196
    /**