LanguageCodeChecker   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A languageCodeExists() 0 3 1
A getLanguageNameByCode() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliqArts\DirectTranslator\Utility;
6
7
use ReliqArts\DirectTranslator\Constant\LanguageCodes;
8
9
/**
10
 * Class LanguageCodeChecker.
11
 *
12
 * @codeCoverageIgnore
13
 */
14
class LanguageCodeChecker
15
{
16
    /**
17
     * @param string $code
18
     *
19
     * @return bool
20
     */
21
    public function languageCodeExists(string $code): bool
22
    {
23
        return !empty($this->getLanguageNameByCode($code));
24
    }
25
26
    /**
27
     * @param string $code
28
     *
29
     * @return string
30
     */
31
    private function getLanguageNameByCode(string $code): string
32
    {
33
        return LanguageCodes::ISO6391[$code] ?? '';
34
    }
35
}
36