SmsirServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 51
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 29 2
A register() 0 8 1
1
<?php
2
3
namespace Cryptommer\Smsir;
4
5
use Cryptommer\Smsir\Classes\Smsir;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Cryptommer\Smsir\Smsir. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
6
use Illuminate\Support\ServiceProvider;
7
8
class SmsirServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        /*
16
         * Optional methods to load your package assets
17
         */
18
         $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'Smsir');
19
        // $this->loadViewsFrom(__DIR__.'/../resources/views', 'Smsir');
20
        // $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
21
        // $this->loadRoutesFrom(__DIR__.'/routes.php');
22
23
        if ($this->app->runningInConsole()) {
24
            $this->publishes([
25
                __DIR__.'/../config/config.php' => config_path('smsir.php'),
26
            ], 'config');
27
28
            // Publishing the views.
29
            /*$this->publishes([
30
                __DIR__.'/../resources/views' => resource_path('views/vendor/Smsir'),
31
            ], 'views');*/
32
33
            // Publishing assets.
34
            /*$this->publishes([
35
                __DIR__.'/../resources/assets' => public_path('vendor/Smsir'),
36
            ], 'assets');*/
37
38
            // Publishing the translation files.
39
            $this->publishes([
40
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/Smsir'),
41
            ], 'lang');
42
43
            // Registering package commands.
44
            // $this->commands([]);
45
        }
46
    }
47
48
    /**
49
     * Register the application services.
50
     */
51
    public function register()
52
    {
53
        // Automatically apply the package configuration
54
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'smsir');
55
56
        // Register the main class to use with the facade
57
        $this->app->singleton('Smsir', function () {
58
            return new Smsir();
59
        });
60
    }
61
}
62