Created
November 13, 2008 19:00
-
-
Save rmasters/24560 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Comment block | |
* @author: Ross Masters <[email protected]> | |
* @build 1 | |
*/ | |
final class Dog extends Quadroped { | |
public $name; | |
private $breed; | |
private $sex; | |
public function __construct($name, $breed, $male = true) { | |
$this->name = $name; | |
$this->breed = Dog::getBreed((int) $breed); | |
$this->sex = ($male) ? 'm' : 'f'; | |
} | |
public static function getBreed($breed) { | |
$breeds = array( | |
1 => 'yorkshire terrier', | |
2 => 'jack russel terrier', | |
3 => 'labrador' | |
); | |
if (array_key_exists((int) $breed, $breeds)) { | |
return $breeds[$breed]; | |
} else { | |
return false; | |
} | |
//Debug | |
echo "Breed: $breeds[$breed] ($breed)\n"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment