Completed
Pull Request — master (#4)
by ARCANEDEV
03:40
created

FoundationServiceProvider::publishAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php namespace Arcanesoft\Foundation;
2
3
use Arcanesoft\Core\Bases\PackageServiceProvider;
4
5
/**
6
 * Class     FoundationServiceProvider
7
 *
8
 * @package  Arcanesoft\Foundation
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class FoundationServiceProvider extends PackageServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Package name.
19
     *
20
     * @var string
21
     */
22
    protected $package = 'foundation';
23
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Getters & Setters
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    /**
29
     * Get the base path of the package.
30
     *
31
     * @return string
32
     */
33 24
    public function getBasePath()
34
    {
35 24
        return dirname(__DIR__);
36
    }
37
38
    /* ------------------------------------------------------------------------------------------------
39
     |  Main Functions
40
     | ------------------------------------------------------------------------------------------------
41
     */
42
    /**
43
     * Register the service provider.
44
     */
45 24
    public function register()
46
    {
47 24
        $this->registerConfig();
48 24
        $this->registerSidebarItems();
49 24
        $this->registerServiceProviders();
50 24
        $this->registerFoundationService();
51
52 24
        if ($this->app->runningInConsole()) {
53 24
            $this->app->register(Providers\CommandServiceProvider::class);
54 18
        }
55 24
    }
56
57
    /**
58
     * Boot the service provider.
59
     */
60 24
    public function boot()
61
    {
62 24
        $this->app->register(Providers\RouteServiceProvider::class);
63 24
        $this->app->register(Providers\ComposerServiceProvider::class);
64
65
        // Publishes
66 24
        $this->publishConfig();
0 ignored issues
show
Bug introduced by
The method publishConfig() does not exist on Arcanesoft\Foundation\FoundationServiceProvider. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
67 24
        $this->publishViews();
0 ignored issues
show
Documentation Bug introduced by
The method publishViews does not exist on object<Arcanesoft\Founda...ndationServiceProvider>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
68 24
        $this->publishTranslations();
0 ignored issues
show
Documentation Bug introduced by
The method publishTranslations does not exist on object<Arcanesoft\Founda...ndationServiceProvider>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
69 24
        $this->publishSidebarItems();
70 24
        $this->publishAssets();
71 24
    }
72
73
    /**
74
     * Get the services provided by the provider.
75
     *
76
     * @return array
77
     */
78 4
    public function provides()
79
    {
80 4
        return ['arcanesoft.foundation'];
81
    }
82
83
    /* ------------------------------------------------------------------------------------------------
84
     |  Services Functions
85
     | ------------------------------------------------------------------------------------------------
86
     */
87
    /**
88
     * Register all the required service providers.
89
     */
90 24
    private function registerServiceProviders()
91
    {
92 24
        $this->app->register(\Arcanesoft\Core\CoreServiceProvider::class);
93 24
        $this->app->register(Providers\PackagesServiceProvider::class);
94 24
        $this->app->register(Providers\ModuleServiceProvider::class);
95 24
        $this->app->register(Providers\AuthorizationServiceProvider::class);
96 24
    }
97
98
    /**
99
     * Register Foundation service.
100
     */
101 24
    private function registerFoundationService()
102
    {
103 24
        $this->singleton('arcanesoft.foundation', Foundation::class);
104 24
    }
105
106
    /* ------------------------------------------------------------------------------------------------
107
     |  Other Functions
108
     | ------------------------------------------------------------------------------------------------
109
     */
110
    /**
111
     * Publish assets.
112
     */
113 24
    private function publishAssets()
114
    {
115 24
        $this->publishes([
116 24
            $this->getBasePath() . '/resources/assets/dist' => public_path("vendor/{$this->package}"),
117 24
        ], 'assets');
118 24
    }
119
}
120