Completed
Push — master ( d3870a...2c6c1e )
by Loban
06:16
created

LocaleHelperTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 12
ccs 3
cts 3
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPrimaryLanguage() 0 5 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: loal
5
 * Date: 04.07.16
6
 * Time: 15:10
7
 */
8
9
namespace lav45\translate;
10
11
use Locale;
12
13
trait LocaleHelperTrait
14
{
15
    /**
16
     * @param string $locale `en-EN`, `ru-RU`
17
     * @return string en or ru
18
     */
19 15
    public function getPrimaryLanguage($locale)
20
    {
21 15
        return extension_loaded('intl') ?
22 15
            Locale::getPrimaryLanguage($locale) : substr($locale, 0, 2);
23
    }
24
}