-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwall.php
53 lines (45 loc) · 1.22 KB
/
wall.php
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
<?php
class Wall
{
protected $beers;
protected $bottlesOfBeer = " bottles of beer ";
protected $onTheWall = "on the wall, ";
protected $passAround = " take one down one pass it around ";
protected $outOfBeer = " what the hell! I'm out of beer!";
public function validate($input)
{
if (ctype_digit(strval($input))) {
return true;
}
return false;
}
public function bottles($beers = 0)
{
$this->beers = $beers;
}
public function howManyBottles($response = '')
{
if ($this->beers == 1) {
$response .= $this->beers.
$this->bottlesOfBeer.
$this->onTheWall.
$this->beers.
$this->bottlesOfBeer.
$this->outOfBeer.
'<hr>';
return $response;
}
return $this->howManyBottles(
$response.
$this->beers.
$this->bottlesOfBeer.
$this->onTheWall.
$this->beers.
$this->bottlesOfBeer.
$this->passAround.
--$this->beers.
$this->bottlesOfBeer.
'<br>'
);
}
}