AuthServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A registerAuthenticator() 0 6 1
A boot() 0 10 3
1
<?php
2
3
namespace Magister\Services\Auth;
4
5
use Magister\Services\Support\ServiceProvider;
6
7
/**
8
 * Class AuthServiceProvider.
9
 */
10
class AuthServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Register bindings in the container.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
        $this->registerAuthenticator();
20
    }
21
22
    /**
23
     * Register the authenticator services.
24
     *
25
     * @return void
26
     */
27
    protected function registerAuthenticator()
28
    {
29
        $this->app->singleton('auth', function ($app) {
30
            return new AuthManager($app);
31
        });
32
    }
33
34
    /**
35
     * Perform booting of services.
36
     *
37
     * @return void
38
     */
39
    public function boot()
40
    {
41
        if ($this->app->bound('credentials')) {
42
            $auth = $this->app->auth;
0 ignored issues
show
Documentation introduced by
The property auth does not exist on object<Magister\Magister>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
43
44
            if (!$auth->check()) {
45
                $auth->attempt($this->app['credentials']);
46
            }
47
        }
48
    }
49
}
50