Completed
Push — master ( bbe544...1bc078 )
by ReliQ
03:23 queued 11s
created

LanguageCodeChecker   A

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
class LanguageCodeChecker
10
{
11
    /**
12
     * @param string $code
13
     *
14
     * @return bool
15
     */
16
    public function languageCodeExists(string $code): bool
17
    {
18
        return !empty($this->getLanguageNameByCode($code));
19
    }
20
21
    /**
22
     * @param string $code
23
     *
24
     * @return string
25
     */
26
    private function getLanguageNameByCode(string $code): string
27
    {
28
        return LanguageCodes::ISO6391[$code] ?? '';
29
    }
30
}
31