Completed
Push — master ( 6505af...82dfad )
by resu
02:14
created

ContainerAwareTrait::getClassMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-usuario project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\User\Traits;
13
14
use Da\User\Helper\AuthHelper;
15
use Da\User\Helper\ClassMapHelper;
16
use Yii;
17
use yii\di\Container;
18
19
/**
20
 * @property-read Container $di
21
 * @property-ready Da\User\Helper\AuthHelper $auth
22
 * @property-ready Da\User\Helper\ClassMapHelper $classMap
23
 */
24
trait ContainerAwareTrait
25
{
26
    /**
27
     * @return Container
28
     */
29 10
    public function getDi()
30
    {
31 10
        return Yii::$container;
32
    }
33
34
    /**
35
     * Gets a class from the container.
36
     *
37
     * @param string $class  he class name or an alias name (e.g. `foo`) that was previously registered via [[set()]]
38
     *                       or [[setSingleton()]]
39
     * @param array  $params constructor parameters
40
     * @param array  $config attributes
41
     *
42
     * @return object
43
     */
44 10
    public function make($class, $params = [], $config = [])
45
    {
46 10
        return $this->getDi()->get($class, $params, $config);
47
    }
48
49
    /**
50
     * @return \Da\User\Helper\AuthHelper
51
     */
52 2
    public function getAuth()
53
    {
54 2
        return $this->getDi()->get(AuthHelper::class);
55
    }
56
57
    /**
58
     * @return \Da\User\Helper\ClassMapHelper
59
     */
60 4
    public function getClassMap()
61
    {
62 4
        return $this->getDi()->get(ClassMapHelper::class);
63
    }
64
}
65