CountryCollection::orderByName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 5
cp 0.8
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2.032
1
<?php
2
3
namespace GeoBase\Countries\Country;
4
5
use GeoBase\Countries\ArrayCollection;
6
use GeoBase\Countries\Coordinate\CoordinateCollectionInterface;
7
use GeoBase\Countries\Language\LanguageEntity;
8
9
/**
10
 * @method CountryEntity get($key)
11
 */
12
class CountryCollection extends ArrayCollection implements CoordinateCollectionInterface
13
{
14
    /**
15
     * @param string|LanguageEntity $language
16
     *
17
     * @return $this
18
     */
19 1
    public function orderByName($language)
20
    {
21 1
        if ($language instanceof LanguageEntity) {
22
            $language = $language->getCode();
23
        }
24 1
        $this->order("names.{$language}.name");
25
26 1
        return $this;
27
    }
28
}
29