NationalityService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findAll() 0 4 1
A find() 0 6 1
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
}