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

Config::config()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 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