LanguageCodeChecker::getLanguageNameByCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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