Fakenews   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 263
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 178
c 2
b 0
f 0
dl 0
loc 263
rs 10
wmc 13

13 Methods

Rating   Name   Duplication   Size   Complexity  
A job() 0 5 1
A headline() 0 4 1
A group() 0 4 1
A celeb() 0 4 1
A anything() 0 5 1
A child() 0 4 1
A badthing() 0 4 1
A person() 0 7 1
A adult() 0 4 1
A location() 0 7 1
A goodthing() 0 4 1
A leader() 0 4 1
A event() 0 3 1
1
<?php
2
3
namespace Faker\Provider;
4
5
class Fakenews extends \Faker\Provider\Base
6
{
7
    protected static $leaderjobs = [
8
        "CEO",
9
        "banker",
10
        "consultant",
11
        "doctor",
12
        "lawyer",
13
        "policeman",
14
        "priest",
15
        "author",
16
        "journalist",
17
        "scientist",
18
        "teacher",
19
    ];
20
21
    protected static $celebjobs =[
22
        "actor",
23
        "actress",
24
        "author",
25
        "celebrity",
26
        "game show host",
27
        "instagram influencer",
28
        "movie star",
29
        "reality show contestant",
30
        "singer",
31
        "tv star",
32
        "viral sensation",
33
        "you tube star",
34
    ];
35
36
    protected static $leaders = [
37
        "President",
38
        "politician",
39
        "Mayor",
40
        "Council Member",
41
        "City leader",
42
43
    ];
44
45
    protected static $animals =[
46
        "dog",
47
        "cat",
48
        "tiger",
49
        "panda",
50
        "parrot",
51
        "duck",
52
        "fish",
53
    ];
54
55
    protected static $groups = [
56
        "children",
57
        "doctors",
58
        "firefighters",
59
        "heavily obese",
60
        "journalists",
61
        "lawyers",
62
        "pensioners",
63
        "people",
64
        "police officers",
65
        "politicians",
66
        "programers",
67
        "scientists",
68
        "seniors",
69
        "shop workers",
70
        "teachers",
71
        "teenagers",
72
    ];
73
74
75
    protected static $adults = [
76
        "dad",
77
        "grandma",
78
        "grandpa",
79
        "man",
80
        "mum",
81
        "pensioner",
82
        "woman",
83
    ];
84
85
    protected static $children =[
86
        "baby",
87
        "boy",
88
        "child",
89
        "girl",
90
        "newborn",
91
        "teen",
92
        "toddler",
93
        "youth",
94
95
    ];
96
97
    protected static $badthings = [
98
        "cars",
99
        "computer virus",
100
        "flu",
101
        "obesity",
102
        "smart phones",
103
        "sugar",
104
        "increased tax",
105
        "vaccines",
106
        "science",
107
    ];
108
109
    protected static $goodthings = [
110
        "cats",
111
        "coffee",
112
        "smart phones",
113
        "dogs",
114
        "children",
115
        "local hero",
116
        "award winning movie",
117
        "award wining book",
118
        "hit tv show",
119
        "top single",
120
        "best selling children's book",
121
        "new toy fad",
122
    ];
123
124
    protected static $events = [
125
        "wins lottery",
126
        "arrested for crime",
127
        "awarded multi million payout",
128
        "loses legal case",
129
        "acquitted",
130
        "gets married by mistake",
131
        "caught in embarrassing video",
132
        "wins international award",
133
        "gets stuck in tree",
134
        "chased by dog",
135
        "kicked out of restaurant",
136
        "conspired to defraud millions",
137
        "selected for international team",
138
        "targeted by online harassment",
139
        "finds love at last",
140
        "exhibits local art show",
141
        "takes to the stage after organizational mix up",
142
    ];
143
144
    protected static $headlineFormats = [
145
        "What's the truth about {{badthing}}?",
146
        "Are you at risk of {{badthing}}?",
147
        "Is it worth becoming a {{job}}?",
148
        "My fears as a leading {{job}}",
149
        "Search finds missing {{location}} {{child}} safe at home",
150
        "{{badthing}} scandal: What we know so far",
151
        "{{celeb}} shares feelings about {{anything}}",
152
        "{{group}} demand apology after {{location}} {{person}}'s remarks",
153
        "{{group}} more intelligent than average",
154
        "{{group}} want to ban {{badthing}}",
155
        "{{job}} admits hatred of {{badthing}}",
156
        "{{job}} praises amazing {{group}}",
157
        "{{leader}} declares war on {{country}}",
158
        "{{leader}} honours {{group}}",
159
        "{{leader}} resigns over {{badthing}} scandal",
160
        "{{location}} author tops readers favourites",
161
        "{{location}} {{adult}} {{event}}",
162
        "{{location}} {{adult}} {{event}}",
163
        "{{location}} {{group}} call for strike",
164
        "{{location}} {{group}} demand fairer pay",
165
        "{{location}} {{person}} {{event}}",
166
        "{{location}} {{person}} {{event}}",
167
        "{{location}} {{person}} {{event}}",
168
        "{{location}} {{person}} {{event}}",
169
        "{{location}} {{person}} {{event}}",
170
        "{{person}} admits relationship with {{person}}",
171
        "{{person}} denies obsession with {{goodthing}}",
172
        "{{person}} to testify about {{badthing}} scandal",
173
        "{{person}}: The truth behind the {{badthing}} story",
174
    ];
175
176
    public static function person()
177
    {
178
        return static::randomElement(array_merge(
179
            static::$leaderjobs,
180
            static::$celebjobs,
181
            static::$leaders,
182
            static::$adults,
183
        ));
184
    }
185
    public static function celeb()
186
    {
187
        return static::randomElement(array_merge(
188
            static::$celebjobs,
189
        ));
190
    }
191
192
    public static function job()
193
    {
194
        return static::randomElement(array_merge(
195
            static::$leaderjobs,
196
            static::$celebjobs,
197
        ));
198
    }
199
200
    public static function event()
201
    {
202
        return static::randomElement(static::$events);
203
    }
204
    public static function leader()
205
    {
206
        return static::randomElement(array_merge(
207
            static::$leaders,
208
        ));
209
    }
210
211
    public static function adult()
212
    {
213
        return static::randomElement(array_merge(
214
            static::$adults
215
        ));
216
    }
217
218
    public static function child()
219
    {
220
        return static::randomElement(array_merge(
221
            static::$children
222
        ));
223
    }
224
225
    public static function group()
226
    {
227
        return static::randomElement(array_merge(
228
            static::$groups
229
        ));
230
    }
231
232
233
    public static function goodthing()
234
    {
235
        return static::randomElement(array_merge(
236
            static::$goodthings,
237
        ));
238
    }
239
240
    public static function badthing()
241
    {
242
        return static::randomElement(array_merge(
243
            static::$badthings
244
        ));
245
    }
246
    public static function anything()
247
    {
248
        return static::randomElement(array_merge(
249
            static::$goodthings,
250
            static::$badthings
251
        ));
252
    }
253
254
    public function location()
255
    {
256
        return static::randomElement([
257
            $this->generator->city,
258
            $this->generator->city,
259
            $this->generator->state,
260
            $this->generator->country,
261
        ]);
262
    }
263
264
    public function headline(): string
265
    {
266
        $headline = static::randomElement(static::$headlineFormats);
267
        return ucfirst($this->generator->parse($this->generator->parse($headline)));
268
    }
269
}
270