Skip to content

Commit 9eaae78

Browse files
committed
moving the sayings into their own class
1 parent fbb04c5 commit 9eaae78

File tree

3 files changed

+111
-64
lines changed

3 files changed

+111
-64
lines changed

src/PatternLab/Console/Commands/GenerateCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use \PatternLab\Console;
1515
use \PatternLab\Console\Command;
1616
use \PatternLab\Generator;
17+
use \PatternLab\Saying;
1718
use \PatternLab\Timer;
1819

1920
class GenerateCommand extends Command {
@@ -39,7 +40,9 @@ public function run() {
3940

4041
$g = new Generator();
4142
$g->generate($options);
42-
$g->printSaying();
43+
44+
$s = new Saying();
45+
$s->say();
4346

4447
}
4548

src/PatternLab/Generator.php

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -158,67 +158,4 @@ protected function moveStatic() {
158158

159159
}
160160

161-
/**
162-
* Randomly prints a saying after the generate is complete
163-
*/
164-
public function printSaying() {
165-
166-
$randomNumber = rand(0,3);
167-
$colors = array("ok","options","info","warning","error");
168-
$color = (isset($colors[$randomNumber])) ? $colors[$randomNumber] : "desc";
169-
170-
$randomNumber = rand(0,60);
171-
$sayings = array(
172-
"have fun storming the castle",
173-
"be well, do good work, and keep in touch",
174-
"may the sun shine, all day long",
175-
"smile :)",
176-
"namaste",
177-
"walk as if you are kissing the earth with your feet",
178-
"to be beautiful means to be yourself",
179-
"i was thinking of the immortal words of socrates, who said '...i drank what?'",
180-
"let me take this moment to compliment you on your fashion sense, particularly your slippers",
181-
"42",
182-
"he who controls the spice controls the universe",
183-
"the greatest thing you'll ever learn is just to love and be loved in return",
184-
"nice wand",
185-
"i don't have time for a grudge match with every poseur in a parka",
186-
"han shot first",
187-
"what we've got here is a failure to communicate",
188-
"mama always said life was like a box of chocolates. you never know what you're gonna get",
189-
"soylent green is people",
190-
"a little word of advice, my friend. sometimes you gotta let those hard-to-reach chips go",
191-
"you don't understand! i coulda had class. i coulda been a contender. i could've been somebody, instead of a bum, which is what i am",
192-
"shop smart. shop s-mart",
193-
"i see dead people",
194-
"well, nobody's perfect",
195-
"it's alive! it's alive!",
196-
"you've got to ask yourself one question: 'do I feel lucky?' well, do ya, punk?",
197-
"badges? we ain't got no badges! we don't need no badges! i don't have to show you any stinking badges!",
198-
"the holy roman empire was neither holy nor roman. discuss.",
199-
"well, here's another nice mess you've gotten me into!",
200-
"here's johnny!",
201-
"hello, gorgeous",
202-
"nobody puts baby in a corner",
203-
"life moves pretty fast. if you don't stop and look around once in a while, you could miss it",
204-
"my precious",
205-
"be yourself; everyone else is already taken",
206-
"the ships hung in the sky in much the same way that bricks don't",
207-
"klaatu barada nikto",
208-
"i am putting myself to the fullest possible use, which is all i think that any conscious entity can ever hope to do",
209-
"just what do you think you're doing, dave?",
210-
"do what i do. hold tight and pretend it's a plan!",
211-
"(╯°□°)╯︵ ┻━┻",
212-
"¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>",
213-
"@}~}~~~",
214-
"(>'.')> (>'.')> (>'.')> ",
215-
"\(^-^)/",
216-
"you've been at this awhile; perhaps it's time for a walk outside?"
217-
);
218-
if (isset($sayings[$randomNumber])) {
219-
Console::writeLine("<".$color.">".$sayings[$randomNumber]."...</".$color.">");
220-
}
221-
222-
}
223-
224161
}

src/PatternLab/Saying.php

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
3+
/*!
4+
* Saying Class
5+
*
6+
* Copyright (c) 2016 Dave Olsen, http://dmolsen.com
7+
* Licensed under the MIT license
8+
*
9+
* Load and print sayings
10+
*
11+
*/
12+
13+
namespace PatternLab;
14+
15+
use \PatternLab\Config;
16+
use \PatternLab\Console;
17+
use \PatternLab\Timer;
18+
19+
class Saying {
20+
21+
protected $sayings;
22+
23+
/**
24+
* Construct the sayings
25+
*/
26+
public function __construct() {
27+
28+
// build the default sayings
29+
$sayings = array( "have fun storming the castle",
30+
"be well, do good work, and keep in touch",
31+
"may the sun shine, all day long",
32+
"smile :)",
33+
"namaste",
34+
"walk as if you are kissing the earth with your feet",
35+
"to be beautiful means to be yourself",
36+
"i was thinking of the immortal words of socrates, who said '...i drank what?'",
37+
"let me take this moment to compliment you on your fashion sense, particularly your slippers",
38+
"42",
39+
"he who controls the spice controls the universe",
40+
"the greatest thing you'll ever learn is just to love and be loved in return",
41+
"nice wand",
42+
"i don't have time for a grudge match with every poseur in a parka",
43+
"han shot first",
44+
"what we've got here is a failure to communicate",
45+
"mama always said life was like a box of chocolates. you never know what you're gonna get",
46+
"soylent green is people",
47+
"a little word of advice, my friend. sometimes you gotta let those hard-to-reach chips go",
48+
"you don't understand! i coulda had class. i coulda been a contender. i could've been somebody, instead of a bum, which is what i am",
49+
"shop smart. shop s-mart",
50+
"i see dead people",
51+
"well, nobody's perfect",
52+
"it's alive! it's alive!",
53+
"you've got to ask yourself one question: 'do I feel lucky?' well, do ya, punk?",
54+
"badges? we ain't got no badges! we don't need no badges! i don't have to show you any stinking badges!",
55+
"the holy roman empire was neither holy nor roman. discuss.",
56+
"well, here's another nice mess you've gotten me into!",
57+
"here's johnny!",
58+
"hello, gorgeous",
59+
"nobody puts baby in a corner",
60+
"life moves pretty fast. if you don't stop and look around once in a while, you could miss it",
61+
"my precious",
62+
"be yourself; everyone else is already taken",
63+
"the ships hung in the sky in much the same way that bricks don't",
64+
"klaatu barada nikto",
65+
"i am putting myself to the fullest possible use, which is all i think that any conscious entity can ever hope to do",
66+
"just what do you think you're doing, dave?",
67+
"do what i do. hold tight and pretend it's a plan!",
68+
"(╯°□°)╯︵ ┻━┻",
69+
"¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>",
70+
"@}~}~~~",
71+
"(>'.')> (>'.')> (>'.')> ",
72+
"\(^-^)/",
73+
"you've been at this awhile; perhaps it's time for a walk outside?"
74+
);
75+
76+
// grab user sayings
77+
$userSayings = Config::getOption("sayings");
78+
if (is_array($userSayings)) {
79+
$sayings = array_merge($sayings, $userSayings);
80+
}
81+
82+
// i just didn't want to indent the crap above
83+
$this->sayings = $sayings;
84+
85+
print_r($sayings);
86+
87+
}
88+
89+
/**
90+
* Randomly prints a saying after the generate is complete
91+
*/
92+
public function say() {
93+
94+
// set a color
95+
$colors = array("ok","options","info","warning","error");
96+
$randomNumber = rand(0,count($colors)-1);
97+
$color = (isset($colors[$randomNumber])) ? $colors[$randomNumber] : "desc";
98+
99+
// set a 1 in 3 chance that a saying is printed
100+
$randomNumber = rand(0,(count($this->sayings)-1)*3);
101+
if (isset($this->sayings[$randomNumber])) {
102+
Console::writeLine("<".$color.">".$this->sayings[$randomNumber]."...</".$color.">");
103+
}
104+
105+
}
106+
107+
}

0 commit comments

Comments
 (0)