Completed
Push — master ( 0cf9cb...4609c1 )
by Neomerx
01:58
created

BaseCoreData::getGlobalConfiguratorsFromData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 4
nop 1
crap 1
1
<?php namespace Limoncello\Core\Application;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use FastRoute\DataGenerator;
20
use FastRoute\Dispatcher;
21
use Limoncello\Core\Contracts\CoreDataInterface;
22
use Limoncello\Core\Reflection\ClassIsTrait;
23
24
/**
25
 * @package Limoncello\Core
26
 */
27
abstract class BaseCoreData implements CoreDataInterface
28
{
29
    use ClassIsTrait;
30
31
    /**
32
     * @param array $data
33
     *
34
     * @return array
35
     */
36 8
    public static function getRouterParametersFromData(array $data): array
37
    {
38 8
        assert(array_key_exists(self::KEY_ROUTER_PARAMS, $data));
39 8
        $result = $data[self::KEY_ROUTER_PARAMS];
40 8
        assert(empty($result) === false);
41
42 8
        return $result;
43
    }
44
45
    /**
46
     * @param array $data
47
     *
48
     * @return string
49
     */
50 8 View Code Duplication
    public static function getGeneratorFromParametersData(array $data): string
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52 8
        assert(array_key_exists(self::KEY_ROUTER_PARAMS__GENERATOR, $data));
53 8
        $result = $data[self::KEY_ROUTER_PARAMS__GENERATOR];
54 8
        assert(empty($result) === false);
55 8
        assert(static::classImplements($result, DataGenerator::class));
56
57 8
        return $result;
58
    }
59
60
    /**
61
     * @param array $data
62
     *
63
     * @return string
64
     */
65 8 View Code Duplication
    public static function getDispatcherFromParametersData(array $data): string
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
66
    {
67 8
        assert(array_key_exists(self::KEY_ROUTER_PARAMS__DISPATCHER, $data));
68 8
        $result = $data[self::KEY_ROUTER_PARAMS__DISPATCHER];
69 8
        assert(empty($result) === false);
70 8
        assert(static::classImplements($result, Dispatcher::class));
71
72 8
        return $result;
73
    }
74
75
    /**
76
     * @param array $data
77
     *
78
     * @return array
79
     */
80 8
    public static function getRoutesDataFromData(array $data): array
81
    {
82 8
        assert(array_key_exists(self::KEY_ROUTES_DATA, $data));
83 8
        $result = $data[self::KEY_ROUTES_DATA];
84
85 8
        return $result;
86
    }
87
88
    /**
89
     * @param array $data
90
     *
91
     * @return callable[]
92
     */
93 8
    public static function getGlobalConfiguratorsFromData(array $data): array
94
    {
95 8
        assert(array_key_exists(self::KEY_GLOBAL_CONTAINER_CONFIGURATORS, $data));
96 8
        $result = $data[self::KEY_GLOBAL_CONTAINER_CONFIGURATORS];
97
98 8
        return $result;
99
    }
100
101
    /**
102
     * @param array $data
103
     *
104
     * @return array
105
     */
106 8
    public static function getGlobalMiddlewareFromData(array $data): array
107
    {
108 8
        assert(array_key_exists(self::KEY_GLOBAL_MIDDLEWARE, $data));
109 8
        $result = $data[self::KEY_GLOBAL_MIDDLEWARE];
110
111 8
        return $result;
112
    }
113
}
114