AspectManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 46
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createRayDriver() 0 8 1
A createNoneDriver() 0 4 1
A getDefaultDriver() 0 4 1
A getConfigure() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
 * THE SOFTWARE.
12
 *
13
 * This software consists of voluntary contributions made by many individuals
14
 * and is licensed under the MIT license.
15
 *
16
 * Copyright (c) 2015-2020 Yuuki Takezawa
17
 *
18
 */
19
20
namespace Ytake\LaravelAspect;
21
22
use Illuminate\Support\Manager;
23
24
/**
25
 * Class AspectManager
26
 * @method void register(string $module)
27
 * @method void weave()
28
 */
29
class AspectManager extends Manager
30
{
31
    /**
32
     * for ray aop driver
33
     *
34
     * @return AspectDriverInterface
35
     * @throws Exception\ClassNotFoundException
36
     */
37
    protected function createRayDriver(): AspectDriverInterface
38
    {
39
        return new RayAspectKernel(
40
            $this->container,
41
            $this->container['files'],
42
            $this->getConfigure('ray')
43
        );
44
    }
45
46
    /**
47
     * @return AspectDriverInterface
48
     */
49
    protected function createNoneDriver(): AspectDriverInterface
50
    {
51
        return new NullAspectKernel();
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getDefaultDriver()
58
    {
59
        return $this->container['config']->get('ytake-laravel-aop.aspect.default');
60
    }
61
62
    /**
63
     * @param string $driver
64
     *
65
     * @return string[]
66
     */
67
    protected function getConfigure(string $driver): array
68
    {
69
        $aspectConfigure = $this->container['config']->get('ytake-laravel-aop.aspect.drivers');
70
        $aspectConfigure[$driver]['modules'] = $this->container['config']->get('ytake-laravel-aop.aspect.modules', []);
71
72
        return $aspectConfigure[$driver];
73
    }
74
}
75