JokeFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getRandomJoke() 0 3 1
1
<?php
2
3
namespace RobertGarrigos\ChuckNorrisJokes;
4
5
class JokeFactory
6
{
7
    protected $jokes = [
8
        'The First rule of Chuck Norris is: you do not talk about Chuck Norris.',
9
        'Chuck Norris does not wear a condom. Because there is no such thing as protection from Chuck Norris.',
10
        'Chuck Norris\' tears cure cancer. Too bad he has never cried.',
11
        'Chuck Norris counted to infinity... Twice.',
12
    ];
13
14
    public function __construct(array $jokes = null)
15
    {
16
        if ($jokes) {
17
            $this->jokes = $jokes;
18
        }
19
    }
20
21
    public function getRandomJoke()
22
    {
23
        return $this->jokes[array_rand($this->jokes)];
24
    }
25
}
26