Address::samplePrefecture()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Gimei;
4
5
use Gimei\Address\City;
6
use Gimei\Address\Prefecture;
7
use Gimei\Address\Town;
8
9
class Address extends Base
10
{
11
    public $prefecture;
12
    public $city;
13
    public $town;
14
    public $kanji;
15
    public $hiragana;
16
    public $katakana;
17
18
    public function __construct($gender = null)
0 ignored issues
show
Unused Code introduced by
The parameter $gender is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20
        $addresses = Dictionary::create()->addresses;
21
        $prefecture = $this->samplePrefecture($addresses->prefecture);
22
        $city = $this->sampleCity($addresses->city);
23
        $town = $this->sampleTown($addresses->town);
24
25
        $this->prefecture = $prefecture;
26
        $this->city = $city;
27
        $this->town = $town;
28
        $this->kanji = "{$prefecture->kanji}{$city->kanji}{$town->kanji}";
29
        $this->hiragana = "{$prefecture->hiragana}{$city->hiragana}{$town->hiragana}";
30
        $this->katakana = "{$prefecture->katakana}{$city->katakana}{$town->katakana}";
31
    }
32
33
    protected function samplePrefecture($prefectures)
34
    {
35
        $prefecture = static::sample($prefectures);
36
37
        return new Prefecture($prefecture[0], $prefecture[1], $prefecture[2]);
38
    }
39
40
    protected function sampleCity($cities)
41
    {
42
        $city = static::sample($cities);
43
44
        return new City($city[0], $city[1], $city[2]);
45
    }
46
47
    protected function sampleTown($towns)
48
    {
49
        $town = static::sample($towns);
50
51
        return new Town($town[0], $town[1], $town[2]);
52
    }
53
}
54