forked from chriskite/git-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovie_plot.php
More file actions
83 lines (72 loc) · 2.1 KB
/
movie_plot.php
File metadata and controls
83 lines (72 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?
class MoviePlotGenerator {
public static $adjectives = array('sadistic',
'diminuitive',
'fat',
'determined',
'grisly');
public static $occupations = array('movie-critic',
'goat wrangler',
'entrepreneur',
'construction worker',
'dentist',
'archaeologist',
'investment banker',
'baker',
'swimsuit model',
'astronaut');
public static $quirks = array('penchant for melodrama',
'murky past',
'love for puppies',
'taste for blood',
'lust for antiques',
'background in Kung Fu',
'baby on the way',
'57\' Chevy',
'family back in Mexico',
'obsessed with gnomes');
/**
*
* Get the plot of the next blockbuster action flick.
*
* @return string
*/
public function getPlot()
{
$his_adjective = $this->getRandom(self::$adjectives);
$his_occupation = $this->getRandom(self::$occupations);
$his_quirk = $this->getRandom(self::$quirks);
$her_adjective = $this->getRandom(self::$adjectives);
if ($her_adjective == $his_adjective) {
$her_adjective = $this->getRandom(self::$adjectives);
return $her_adjective;
}
$her_occupation = $this->getRandom(self::$occupations);
if ($her_occupation == $his_occupation) {
$her_occupation = $this->getRandom(self::$occupations);
return $her_occupation;
}
$her_quirk = $this->getRandom(self::$quirks);
if ($her_quirk == $his_quirk) {
$her_quirk = $this->getRandom(self::$quirks);
return $her_quirk;
}
$plot = "He's a $his_adjective $his_occupation with a $his_quirk. ";
$plot .= "She's a $her_adjective $her_occupation with a $her_quirk. ";
$plot .= "They fight crime.";
return $plot;
}
/**
*
* Return a random element from the array $arr.
*
* @param array $arr
* @return mixed
*/
protected function getRandom($arr)
{
return $arr[mt_rand(0, count($arr) - 1)];
}
}
$generator = new MoviePlotGenerator();
print $generator->getPlot() . "\n";