|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
namespace DummyGenerator\Core; |
|
6
|
|
|
|
|
7
|
|
|
use DummyGenerator\Definitions\Extension\Awareness\GeneratorAwareExtensionInterface; |
|
8
|
|
|
use DummyGenerator\Definitions\Extension\Awareness\GeneratorAwareExtensionTrait; |
|
9
|
|
|
use DummyGenerator\Definitions\Extension\Awareness\RandomizerAwareExtensionInterface; |
|
10
|
|
|
use DummyGenerator\Definitions\Extension\Awareness\RandomizerAwareExtensionTrait; |
|
11
|
|
|
use DummyGenerator\Definitions\Extension\PersonExtensionInterface; |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class Person implements PersonExtensionInterface, GeneratorAwareExtensionInterface, RandomizerAwareExtensionInterface |
|
14
|
|
|
{ |
|
15
|
|
|
use GeneratorAwareExtensionTrait; |
|
16
|
|
|
use RandomizerAwareExtensionTrait; |
|
17
|
|
|
|
|
18
|
|
|
/** @var string[] */ |
|
19
|
|
|
protected array $titleFormat = [ |
|
20
|
|
|
'{{titleMale}}', |
|
21
|
|
|
'{{titleFemale}}', |
|
22
|
|
|
]; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string[] */ |
|
25
|
|
|
protected array $firstNameFormat = [ |
|
26
|
|
|
'{{firstNameMale}}', |
|
27
|
|
|
'{{firstNameFemale}}', |
|
28
|
|
|
]; |
|
29
|
|
|
|
|
30
|
|
|
/** @var string[] */ |
|
31
|
|
|
protected array $maleNameFormats = [ |
|
32
|
|
|
'{{firstNameMale}} {{lastName}}', |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
/** @var string[] */ |
|
36
|
|
|
protected array $femaleNameFormats = [ |
|
37
|
|
|
'{{firstNameFemale}} {{lastName}}', |
|
38
|
|
|
]; |
|
39
|
|
|
|
|
40
|
|
|
/** @var string[] */ |
|
41
|
|
|
protected array $firstNameMale = [ |
|
42
|
|
|
'John', 'Harry', 'Olivier', |
|
43
|
|
|
]; |
|
44
|
|
|
|
|
45
|
|
|
/** @var string[] */ |
|
46
|
|
|
protected array $firstNameFemale = [ |
|
47
|
|
|
'Jane', 'Katy', 'Anna', |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
/** @var string[] */ |
|
51
|
|
|
protected array $lastName = ['Doe', 'Smith', 'White']; |
|
52
|
|
|
|
|
53
|
|
|
/** @var string[] */ |
|
54
|
|
|
protected array $titleMale = ['Mr.', 'Dr.', 'Prof.']; |
|
55
|
|
|
|
|
56
|
|
|
/** @var string[] */ |
|
57
|
|
|
protected array $titleFemale = ['Mrs.', 'Ms.', 'Miss', 'Dr.', 'Prof.']; |
|
58
|
|
|
|
|
59
|
2 |
|
public function name(?string $gender = null): string |
|
60
|
|
|
{ |
|
61
|
2 |
|
if ($gender === static::GENDER_MALE) { |
|
62
|
1 |
|
$format = $this->randomizer->randomElement($this->maleNameFormats); |
|
63
|
2 |
|
} elseif ($gender === static::GENDER_FEMALE) { |
|
64
|
1 |
|
$format = $this->randomizer->randomElement($this->femaleNameFormats); |
|
65
|
|
|
} else { |
|
66
|
2 |
|
$format = $this->randomizer->randomElement(array_merge($this->maleNameFormats, $this->femaleNameFormats)); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
2 |
|
return $this->generator->parse($format); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
7 |
|
public function firstName(?string $gender = null): string |
|
73
|
|
|
{ |
|
74
|
7 |
|
if ($gender === static::GENDER_MALE) { |
|
75
|
1 |
|
return $this->firstNameMale(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
7 |
|
if ($gender === static::GENDER_FEMALE) { |
|
79
|
1 |
|
return $this->firstNameFemale(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
7 |
|
return $this->generator->parse($this->randomizer->randomElement($this->firstNameFormat)); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
7 |
|
public function firstNameMale(): string |
|
86
|
|
|
{ |
|
87
|
7 |
|
return $this->randomizer->randomElement($this->firstNameMale); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
6 |
|
public function firstNameFemale(): string |
|
91
|
|
|
{ |
|
92
|
6 |
|
return $this->randomizer->randomElement($this->firstNameFemale); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
14 |
|
public function lastName(): string |
|
96
|
|
|
{ |
|
97
|
14 |
|
return $this->randomizer->randomElement($this->lastName); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
1 |
|
public function title(?string $gender = null): string |
|
101
|
|
|
{ |
|
102
|
1 |
|
if ($gender === static::GENDER_MALE) { |
|
103
|
1 |
|
return $this->titleMale(); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
1 |
|
if ($gender === static::GENDER_FEMALE) { |
|
107
|
1 |
|
return $this->titleFemale(); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
1 |
|
return $this->generator->parse($this->randomizer->randomElement($this->titleFormat)); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
2 |
|
public function titleMale(): string |
|
114
|
|
|
{ |
|
115
|
2 |
|
return $this->randomizer->randomElement($this->titleMale); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
2 |
|
public function titleFemale(): string |
|
119
|
|
|
{ |
|
120
|
2 |
|
return $this->randomizer->randomElement($this->titleFemale); |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths