Completed
Push — master ( a70bce...487388 )
by
unknown
16:07 queued 15:54
created

Environment::getApplicationEnv()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 0
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
namespace PyzTest\Shared\Testify\Helper;
9
10
use Codeception\Module;
11
use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfig;
12
use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfigInterface;
13
14
class Environment extends Module
15
{
16
    /**
17
     * @var string
18
     */
19
    protected const TESTING_APPLICATION_ENV_NAME = 'devtest';
20
21
    /**
22
     * @return void
23
     */
24
    public function _initialize(): void
25
    {
26
        $rootDir = realpath(__DIR__ . '/../../../../../../');
27
        $applicationEnv = $this->getApplicationEnv();
28
29
        defined('APPLICATION_ENV') || define('APPLICATION_ENV', $applicationEnv);
30
        defined('APPLICATION_STORE') || define('APPLICATION_STORE', (isset($_SERVER['APPLICATION_STORE'])) ? $_SERVER['APPLICATION_STORE'] : 'DE');
31
        putenv('APPLICATION_STORE=' . APPLICATION_STORE);
32
33
        defined('APPLICATION') || define('APPLICATION', '');
34
35
        defined('APPLICATION_ROOT_DIR') || define('APPLICATION_ROOT_DIR', $rootDir);
36
        defined('APPLICATION_SOURCE_DIR') || define('APPLICATION_SOURCE_DIR', APPLICATION_ROOT_DIR . '/src');
37
        defined('APPLICATION_VENDOR_DIR') || define('APPLICATION_VENDOR_DIR', APPLICATION_ROOT_DIR . '/vendor');
38
39
        defined('APPLICATION_CODE_BUCKET') || define('APPLICATION_CODE_BUCKET', $this->createCodeBucketConfig()->getCurrentCodeBucket());
40
        putenv('APPLICATION_CODE_BUCKET=' . APPLICATION_CODE_BUCKET);
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    protected function getApplicationEnv(): string
47
    {
48
        if (getenv('SPRYKER_TESTING_ENABLED')) {
49
            return getenv('APPLICATION_ENV');
50
        }
51
52
        return static::TESTING_APPLICATION_ENV_NAME;
53
    }
54
55
    /**
56
     * @return \Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfigInterface
57
     */
58
    protected function createCodeBucketConfig(): CodeBucketConfigInterface
59
    {
60
        return new CodeBucketConfig();
61
    }
62
}
63