Completed
Push — develop ( ea9a36...1bc5bd )
by Neomerx
05:01
created

anonymous//src/Packages/Cors/CorsSettings.php$0   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1
rs 10
ccs 0
cts 0
cp 0
1
<?php namespace Limoncello\Application\Packages\Cors;
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 Limoncello\Contracts\Settings\SettingsInterface;
20
use Neomerx\Cors\Strategies\Settings;
21
22
/**
23
 * @package Limoncello\Application
24
 */
25
class CorsSettings implements SettingsInterface
26
{
27
    /** @see Settings */
28
    const VALUE_ALLOW_ORIGIN_ALL = Settings::VALUE_ALLOW_ORIGIN_ALL;
29
30
    /** @see Settings */
31
    const KEY_SERVER_ORIGIN = Settings::KEY_SERVER_ORIGIN;
32
33
    /** @see Settings */
34
    const KEY_SERVER_ORIGIN_SCHEME = Settings::KEY_SERVER_ORIGIN_SCHEME;
35
36 1
    /** @see Settings */
37
    const KEY_SERVER_ORIGIN_HOST = Settings::KEY_SERVER_ORIGIN_HOST;
38 1
39
    /** @see Settings */
40 1
    const KEY_SERVER_ORIGIN_PORT = Settings::KEY_SERVER_ORIGIN_PORT;
41
42 1
    /** @see Settings */
43
    const KEY_ALLOWED_ORIGINS = Settings::KEY_ALLOWED_ORIGINS;
44
45
    /** @see Settings */
46
    const KEY_ALLOWED_METHODS = Settings::KEY_ALLOWED_METHODS;
47
48
    /** @see Settings */
49
    const KEY_ALLOWED_HEADERS = Settings::KEY_ALLOWED_HEADERS;
50
51
    /** @see Settings */
52
    const KEY_EXPOSED_HEADERS = Settings::KEY_EXPOSED_HEADERS;
53
54
    /** @see Settings */
55
    const KEY_IS_USING_CREDENTIALS = Settings::KEY_IS_USING_CREDENTIALS;
56
57
    /** @see Settings */
58
    const KEY_FLIGHT_CACHE_MAX_AGE = Settings::KEY_FLIGHT_CACHE_MAX_AGE;
59
60
    /** @see Settings */
61
    const KEY_IS_FORCE_ADD_METHODS = Settings::KEY_IS_FORCE_ADD_METHODS;
62
63
    /** @see Settings */
64
    const KEY_IS_FORCE_ADD_HEADERS = Settings::KEY_IS_FORCE_ADD_HEADERS;
65
66
    /** @see Settings */
67
    const KEY_IS_CHECK_HOST = Settings::KEY_IS_CHECK_HOST;
68
69
    /** Settings key */
70
    const KEY_LOG_IS_ENABLED = self::KEY_IS_CHECK_HOST + 10;
71
72
    /** Settings key */
73
    const KEY_LAST = self::KEY_LOG_IS_ENABLED;
74
75
    /**
76
     * @inheritdoc
77
     */
78
    final public function get(): array
79
    {
80
        return $this->getSettings();
81
    }
82
83
    /**
84
     * @inheritdoc
85
     */
86
    protected function getSettings(): array
87
    {
88
        // Settings do not provide any public methods to get default settings so we use this trick
89
        $defaults = (new class extends Settings
90
        {
91
            /**
92
             * @return array
93
             */
94
            public function getHiddenDefaults(): array
95
            {
96
                return $this->getDefaultSettings();
97
            }
98
        })->getHiddenDefaults();
99
100
        $defaults[static::KEY_LOG_IS_ENABLED] = false;
101
102
        return $defaults;
103
    }
104
}
105