Fakenewssource::NewspaperName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Faker\Provider;
4
5
class Fakenewssource extends \Faker\Provider\Base
6
{
7
    protected static $sufixes = [
8
        'Herald',
9
        'Mail',
10
        'News',
11
        'Post',
12
        'Record',
13
        'Report',
14
        'Star',
15
        'Sun',
16
        'Telegraph',
17
        'Times',
18
        'Tribune',
19
        'Update',
20
    ];
21
22
    protected static $prefixes = [
23
        'Daily',
24
        'Morning',
25
    ];
26
27
    protected static $newspaperFormats = [
28
        "The {{location}} {{suffix}}",
29
        "The {{location}} {{suffix}}",
30
        "The {{prefix}} {{suffix}}",
31
        "{{location}} {{suffix}}",
32
        "{{location}} {{suffix}}",
33
    ];
34
35
    public static function prefix()
36
    {
37
        return static::randomElement(static::$prefixes);
38
    }
39
40
    public static function suffix()
41
    {
42
        return static::randomElement(static::$sufixes);
43
    }
44
45
    public function location()
46
    {
47
        return static::randomElement([
48
            $this->generator->city,
49
            $this->generator->state,
50
            $this->generator->country,
51
        ]);
52
    }
53
54
    public function TVNewsName(): String
55
    {
56
        $letter = [
57
            strtoupper(static::randomLetter()),
58
            strtoupper(static::randomLetter()),
59
            strtoupper(static::randomLetter()),
60
        ];
61
        $suffix = static::randomElement([
62
            ' News',
63
            ' News',
64
            ' News',
65
            ' 247',
66
            '',
67
            ' TV',
68
        ]);
69
        return static::randomElement([
70
            $letter[0] . $letter[0] . $letter[1] . $suffix,
71
            $letter[0] . $letter[1] . $letter[1] . $suffix,
72
            $letter[0] . $letter[0] . $letter[1] . $suffix,
73
            $letter[0] . $letter[1] . $letter[2] . $suffix,
74
        ]);
75
    }
76
77
    public function NewspaperName(): string
78
    {
79
        $newspapername = static::randomElement(static::$newspaperFormats);
80
        return ucwords($this->generator->parse($newspapername));
81
    }
82
83
    public function NewssourceName() : string
84
    {
85
        return static::randomElement([
86
            $this->NewspaperName(),
87
            $this->NewspaperName(),
88
            $this->NewspaperName(),
89
            $this->TVNewsName(),
90
        ]);
91
    }
92
}
93