Name   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 49
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A isMale() 0 4 1
A isFemale() 0 4 1
A sampleFirstName() 0 6 1
A sampleLastName() 0 6 1
1
<?php
2
3
namespace Gimei;
4
5
use Gimei\Name\FirstName;
6
use Gimei\Name\LastName;
7
8
class Name extends Base
9
{
10
    public $firstName;
11
    public $lastName;
12
    public $kanji;
13
    public $hiragana;
14
    public $katakana;
15
    private $gender;
16
    private $people;
0 ignored issues
show
Unused Code introduced by
The property $people is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
17
18
    public function __construct($gender = null)
19
    {
20
        $people = Dictionary::create()->people;
21
        $gender = new Gender($gender);
22
        $firstName = $this->sampleFirstName($people->first_name->{$gender});
23
        $lastName = $this->sampleLastName($people->last_name);
24
25
        $this->gender = $gender;
26
        $this->firstName = $firstName;
27
        $this->lastName = $lastName;
28
        $this->kanji = "{$lastName->kanji} {$firstName->kanji}";
29
        $this->hiragana = "{$lastName->hiragana} {$firstName->hiragana}";
30
        $this->katakana = "{$lastName->katakana} {$firstName->katakana}";
31
    }
32
33
    public function isMale()
34
    {
35
        return $this->gender->isMale();
36
    }
37
38
    public function isFemale()
39
    {
40
        return $this->gender->isFemale();
41
    }
42
43
    protected function sampleFirstName($firstNames)
44
    {
45
        $firstName = static::sample($firstNames);
46
47
        return new FirstName($firstName[0], $firstName[1], $firstName[2]);
48
    }
49
50
    protected function sampleLastName($lastNames)
51
    {
52
        $lastName = static::sample($lastNames);
53
54
        return new LastName($lastName[0], $lastName[1], $lastName[2]);
55
    }
56
}
57