PropertyFilter::filterByProperty()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 5
nc 3
nop 2
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 4
rs 10
c 1
b 0
f 0
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 8
    protected function filterByProperty(array $locales, $property)
16
    {
17 8
        $filtered = [];
18
19 8
        foreach ($locales as $locale) {
20 4
            if ( ! empty($locale->$property) && ! in_array($locale->$property, $filtered)) {
21 4
                $filtered[] = $locale->$property;
22
            }
23
        }
24
25 8
        return $filtered;
26
    }
27
}
28