NationalityService::findAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the Slince/China package.
4
 *
5
 * (c) Slince <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace China\Nationality;
12
13
use China\Common\ResourceFile;
14
use Doctrine\Common\Collections\Collection;
15
16
class NationalityService implements NationalityServiceInterface
17
{
18
    /**
19
     * @var Collection
20
     */
21
    protected $nationalities;
22
23
    public function __construct(ResourceFile $resourceFile)
24
    {
25
        $this->nationalities = new NationalityLoader($resourceFile);
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function findAll()
32
    {
33
        return $this->nationalities;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function find($name)
40
    {
41
        return $this->nationalities->filter(function(NationalityInterface $nationality) use ($name){
42
            return $nationality->getName() === $name;
43
        })->first();
44
    }
45
}