Test Setup Failed
Pull Request — master (#11)
by
unknown
32:32
created

Iso3166ConverterService::numericToIso2()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 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\Service\ArvatoRss;
9
10
use Spryker\Service\Kernel\AbstractService;
11
use SprykerEco\Shared\ArvatoRss\ArvatoRssCountryConfig;
12
13
class Iso3166ConverterService extends AbstractService implements Iso3166ConverterServiceInterface
14
{
15
    const ISO2_KEY = 'alpha2';
16
    const ISO3166_KEY = 'numeric';
17
18
    /**
19
     * @param string $iso2CountryCode
20
     *
21
     * @return string|null
22
     */
23 View Code Duplication
    public function iso2ToNumeric($iso2CountryCode)
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...
24
    {
25
        $key = $this->searchArrayIndex($iso2CountryCode, static::ISO2_KEY);
26
        if ($key !== false) {
27
            return ArvatoRssCountryConfig::ISO3166[$key][static::ISO3166_KEY];
28
        }
29
30
        return null;
31
    }
32
33
    /**
34
     * @param string $iso3166CountryCode
35
     *
36
     * @return string|null
37
     */
38 View Code Duplication
    public function numericToIso2($iso3166CountryCode)
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...
39
    {
40
        $key = $this->searchArrayIndex($iso3166CountryCode, static::ISO3166_KEY);
41
        if ($key !== false) {
42
            return ArvatoRssCountryConfig::ISO3166[$key][static::ISO2_KEY];
43
        }
44
45
        return null;
46
    }
47
48
    /**
49
     * @param string $value
50
     * @param string $columnName
51
     *
52
     * @return string
53
     */
54
    protected function searchArrayIndex($value, $columnName)
55
    {
56
        return array_search($value, array_column(ArvatoRssCountryConfig::ISO3166, $columnName));
57
    }
58
}
59