Completed
Push — master ( 671383...5c8721 )
by Antonio Carlos
04:32 queued 02:15
created

Config   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A config() 0 10 2
A getAuth() 0 8 2
1
<?php
2
3
namespace PragmaRX\Google2FALaravel\Support;
4
5
trait Config
6
{
7
    /**
8
     * Get a config value.
9
     *
10
     * @param $string
11
     * @param array $children
12
     *
13
     * @throws \Exception
14
     *
15
     * @return mixed
16
     */
17
    protected function config($string, $children = [])
18
    {
19
        if (is_null(config(Constants::CONFIG_PACKAGE_NAME))) {
20
            throw new \Exception('Config not found');
21
        }
22
23
        return config(
24
            implode('.', array_merge([Constants::CONFIG_PACKAGE_NAME, $string], (array) $children))
25
        );
26
    }
27
28
    /**
29
     * Get or make an auth instance.
30
     *
31
     * @return \Illuminate\Foundation\Application|mixed
32
     */
33
    protected function getAuth()
34
    {
35
        if (is_null($this->auth)) {
36
            $this->auth = app($this->config('auth'));
0 ignored issues
show
Bug introduced by
The property auth does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
        }
38
39
        return $this->auth;
40
    }
41
}
42