EcondaConfig   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
eloc 14
c 6
b 0
f 0
dl 0
loc 69
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getEcondaPdoQueryClassName() 0 14 2
A getFileExportPath() 0 3 1
A getCsvDelimiter() 0 3 1
A getHostYves() 0 3 1
A getCsvCategoryDelimiter() 0 3 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Econda;
9
10
use Exception;
11
use Spryker\Shared\Application\ApplicationConstants;
12
use Spryker\Zed\Kernel\AbstractBundleConfig;
13
use SprykerEco\Shared\Econda\EcondaConstants;
14
use SprykerEco\Zed\Econda\Persistence\Storage\Pdo\PostgreSql\CategoryNodeEcondaQuery as StorageCategoryNodeEcondaQuery;
15
use SprykerEco\Zed\Econda\Persistence\Storage\Pdo\PostgreSql\ProductConcreteEcondaQuery as StorageProductConcreteEcondaQuery;
16
17
class EcondaConfig extends AbstractBundleConfig
18
{
19
    protected const ECONDA_CSV_DELIMITER = '|';
20
    protected const ECONDA_CSV_CATEGORY_DELIMITER = '^^';
21
22
    /**
23
     * @api
24
     *
25
     * @return string
26
     */
27
    public function getHostYves(): string
28
    {
29
        return $this->get(ApplicationConstants::HOST_YVES);
30
    }
31
32
    /**
33
     * @api
34
     *
35
     * @return string
36
     */
37
    public function getFileExportPath(): string
38
    {
39
        return $this->get(EcondaConstants::CSV_FOLDER_PATH);
40
    }
41
42
    /**
43
     * @api
44
     *
45
     * @return string
46
     */
47
    public function getCsvDelimiter(): string
48
    {
49
        return static::ECONDA_CSV_DELIMITER;
50
    }
51
52
    /**
53
     * @api
54
     *
55
     * @return string
56
     */
57
    public function getCsvCategoryDelimiter(): string
58
    {
59
        return static::ECONDA_CSV_CATEGORY_DELIMITER;
60
    }
61
62
    /**
63
     * @api
64
     *
65
     * @param string $dbEngineName
66
     * @param string $econdaPdoQueryName
67
     *
68
     * @throws \Exception
69
     *
70
     * @return string
71
     */
72
    public function getEcondaPdoQueryClassName($dbEngineName, $econdaPdoQueryName): string
73
    {
74
        $data = [
75
            'PostgreSql' => [
76
                'CategoryNodeEcondaQuery' => StorageCategoryNodeEcondaQuery::class,
77
                'ProductConcreteEcondaQuery' => StorageProductConcreteEcondaQuery::class,
78
            ],
79
        ];
80
81
        if (!isset($data[$dbEngineName][$econdaPdoQueryName])) {
82
            throw new Exception('Invalid EcondaPdoQueryName name: ' . $econdaPdoQueryName);
83
        }
84
85
        return $data[$dbEngineName][$econdaPdoQueryName];
86
    }
87
}
88