Completed
Pull Request — master (#58)
by Oliver
01:51
created

LaravelLogViewerServiceProvider::getConfigPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Rap2hpoutre\LaravelLogViewer;
2
3
use Illuminate\Support\ServiceProvider;
4
5
class LaravelLogViewerServiceProvider extends ServiceProvider {
6
7
	/**
8
	 * Indicates if loading of the provider is deferred.
9
	 *
10
	 * @var bool
11
	 */
12
	protected $defer = false;
13
14
	/**
15
	 * Bootstrap the application events.
16
	 *
17
	 * @return void
18
	 */
19
	public function boot()
20
	{
21
		if (method_exists($this, 'package')) {
22
			$this->package('rap2hpoutre/laravel-log-viewer', 'laravel-log-viewer', __DIR__ . '/../../');
0 ignored issues
show
Documentation Bug introduced by
The method package does not exist on object<Rap2hpoutre\Larav...gViewerServiceProvider>? 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...
23
		}
24
25
		if (method_exists($this, 'loadViewsFrom')) {
26
			$this->loadViewsFrom(__DIR__.'/../../views', 'laravel-log-viewer');
27
		}
28
29
        $configPath = $this->getConfigPath();
30
        if (function_exists('config_path')) {
31
            $this->publishes([$configPath => config_path('logviewer.php')], 'config');
32
        }
33
	}
34
35
	/**
36
	 * Register the service provider.
37
	 *
38
	 * @return void
39
	 */
40
	public function register()
41
	{
42
        $configPath = $this->getConfigPath();
43
        $this->mergeConfigFrom($configPath, 'logviewer');
44
	}
45
46
	/**
47
	 * Get the services provided by the provider.
48
	 *
49
	 * @return array
50
	 */
51
	public function provides()
52
	{
53
		return array();
54
	}
55
56
    /**
57
     * Returns config path
58
     *
59
     * @return string
60
     */
61
    private function getConfigPath(){
62
        return __DIR__ . '/../../config/logviewer.php';
63
    }
64
65
66
}
67