Environment   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 13
eloc 17
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createCodeBucketConfig() 0 3 1
A getApplicationEnv() 0 7 2
B _initialize() 0 17 10
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace PyzTest\Shared\Testify\Helper;
11
12
use Codeception\Module;
13
use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfig;
14
use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfigInterface;
15
16
class Environment extends Module
17
{
18
    protected const TESTING_APPLICATION_ENV_NAME = 'devtest';
19
20
    public function _initialize(): void
21
    {
22
        $rootDir = realpath(__DIR__ . '/../../../../../../');
23
        $applicationEnv = $this->getApplicationEnv();
24
25
        defined('APPLICATION_ENV') || define('APPLICATION_ENV', $applicationEnv);
26
        defined('APPLICATION_STORE') || define('APPLICATION_STORE', (isset($_SERVER['APPLICATION_STORE']) && $_SERVER['APPLICATION_STORE'] !== '') ? $_SERVER['APPLICATION_STORE'] : 'DE'); // phpcs:ignore SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable
27
        putenv('APPLICATION_STORE=' . APPLICATION_STORE);
28
29
        defined('APPLICATION') || define('APPLICATION', '');
30
31
        defined('APPLICATION_ROOT_DIR') || define('APPLICATION_ROOT_DIR', $rootDir);
32
        defined('APPLICATION_SOURCE_DIR') || define('APPLICATION_SOURCE_DIR', APPLICATION_ROOT_DIR . '/src');
33
        defined('APPLICATION_VENDOR_DIR') || define('APPLICATION_VENDOR_DIR', APPLICATION_ROOT_DIR . '/vendor');
34
35
        defined('APPLICATION_CODE_BUCKET') || define('APPLICATION_CODE_BUCKET', $this->createCodeBucketConfig()->getCurrentCodeBucket());
36
        putenv('APPLICATION_CODE_BUCKET=' . APPLICATION_CODE_BUCKET);
37
    }
38
39
    protected function getApplicationEnv(): string
40
    {
41
        if (getenv('SPRYKER_TESTING_ENABLED')) {
42
            return getenv('APPLICATION_ENV');
43
        }
44
45
        return static::TESTING_APPLICATION_ENV_NAME;
46
    }
47
48
    protected function createCodeBucketConfig(): CodeBucketConfigInterface
49
    {
50
        return new CodeBucketConfig();
51
    }
52
}
53