migrationHasAlreadyBeenPublished()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php 
2
3
namespace Yaro\LogEnvelope;
4
5
class ServiceProvider extends \Illuminate\Support\ServiceProvider
6
{
7
8
    protected $defer = false;
9
10
    /**
11
     * Bootstrap the application events.
12
     */
13
    public function boot()
14
    {
15
        /*
16
         * Publish configuration file
17
         */
18
        $this->publishes([
19
            __DIR__ . '/../config/log-envelope.php' => config_path('yaro.log-envelope.php'),
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
            __DIR__ . '/../config/log-envelope.php' => /** @scrutinizer ignore-call */ config_path('yaro.log-envelope.php'),
Loading history...
20
        ]);
21
22
        /*
23
         * Publish migration if not published yet
24
         */
25
        if (!$this->migrationHasAlreadyBeenPublished()) {
26
            $timestamp = date('Y_m_d_His', time());
27
            $this->publishes([
28
                __DIR__ . '/../resources/migrations/create_exceptions_table.php.stub' => database_path('migrations/' . $timestamp . '_create_exceptions_table.php'),
0 ignored issues
show
Bug introduced by
The function database_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
                __DIR__ . '/../resources/migrations/create_exceptions_table.php.stub' => /** @scrutinizer ignore-call */ database_path('migrations/' . $timestamp . '_create_exceptions_table.php'),
Loading history...
29
            ], 'migrations');
30
        }
31
32
        $this->app['view']->addNamespace('log-envelope', __DIR__ . '/../resources/views');
33
34
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
0 ignored issues
show
Bug introduced by
The type Illuminate\Foundation\AliasLoader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
        $loader->alias('LogEnvelope', 'Yaro\LogEnvelope\Facade');
36
    }
37
38
    /**
39
     * Register the service provider.
40
     */
41
    public function register()
42
    {
43
        config([
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        /** @scrutinizer ignore-call */ 
44
        config([
Loading history...
44
            'config/yaro.log-envelope.php',
45
        ]);
46
47
        $this->app->singleton('yaro.log-envelope', function($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

47
        $this->app->singleton('yaro.log-envelope', function(/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
            return new LogEnvelope();
49
        });
50
    }
51
52
    /**
53
     * @return bool
54
     */
55
    protected function migrationHasAlreadyBeenPublished()
56
    {
57
        $files = glob(database_path('/migrations/*_create_exceptions_table.php'));
0 ignored issues
show
Bug introduced by
The function database_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
        $files = glob(/** @scrutinizer ignore-call */ database_path('/migrations/*_create_exceptions_table.php'));
Loading history...
58
        return count($files) > 0;
59
    }
60
61
}
62