Completed
Push — master ( f0cb91...c4f1d3 )
by Ivan
02:22
created

PropertyFilter::filterByProperty()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.2
cc 4
eloc 6
nc 3
nop 2
crap 4
1
<?php
2
3
namespace CodeZero\BrowserLocale\Filters;
4
5
abstract class PropertyFilter
6
{
7
    /**
8
     * Filter by a Locale property.
9
     *
10
     * @param array $locales
11
     * @param string $property
12
     *
13
     * @return array
14
     */
15 4
    protected function filterByProperty(array $locales, $property)
16
    {
17 4
        $filtered = [];
18
19 4
        foreach ($locales as $locale) {
20 4
            if ( ! empty($locale->$property) && ! in_array($locale->$property, $filtered)) {
21 4
                $filtered[] = $locale->$property;
22
            }
23
        }
24
25 4
        return $filtered;
26
    }
27
}
28