SynchronizerServiceProvider::bootLogger()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 8
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 16
rs 9.4285
1
<?php namespace Algorit\Synchronizer;
2
3
use Illuminate\Filesystem\Filesystem;
4
use Illuminate\Support\ServiceProvider;
5
6
use Monolog\Handler\StreamHandler;
7
use Algorit\Synchronizer\Request\Config;
8
9
use Algorit\Synchronizer\Storage\Sync;
10
use Algorit\Synchronizer\Storage\SyncEloquentRepository;
11
12
class SynchronizerServiceProvider extends ServiceProvider {
13
14
	/**
15
	 * Indicates if loading of the provider is deferred.
16
	 *
17
	 * @var bool
18
	 */
19
	protected $defer = true;
20
21
	/**
22
	 * Bootstrap the application events.
23
	 *
24
	 * @return void
25
	 */
26
	public function boot()
27
	{
28
		$this->package('algorit/synchronizer');
0 ignored issues
show
Documentation Bug introduced by
The method package does not exist on object<Algorit\Synchroni...ronizerServiceProvider>? 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...
29
30
		$this->app['algorit.synchronizer'] = $this->app->share(function($app)
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
		{
32
			$sync = new SyncEloquentRepository(new Sync);
33
34
			$builder = new Builder(new Sender, new Receiver, $sync);
35
36
			return new Loader($app, $builder, new Config(new Filesystem));
37
		});
38
39
		require 'helpers.php';
40
41
		$this->bootLogger();
42
	}
43
44
	public function bootLogger()
45
	{
46
		$logger = $this->app['log'];
47
			
48
		if($logger == false)
49
		{
50
			return false;
51
		}
52
53
		$handler = new StreamHandler('php://output');
54
55
		$monolog = $logger->getMonolog();
56
		$monolog->pushHandler($handler);
57
58
		$this->app['algorit.synchronizer']->setLogger($logger);
59
	}
60
61
	/**
62
	 * Register the service provider.
63
	 *
64
	 * @return void
65
	 */
66
	public function register(){}
67
68
	/**
69
	 * Get the services provided by the provider.
70
	 *
71
	 * @return array
72
	 */
73
	public function provides()
74
	{
75
		return array('algorit.synchronizer');
76
	}
77
78
}