Name::isFemale()   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
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