Skip to content

Instantly share code, notes, and snippets.

@rmasters
Created November 13, 2008 19:00
Show Gist options
  • Save rmasters/24560 to your computer and use it in GitHub Desktop.
Save rmasters/24560 to your computer and use it in GitHub Desktop.
<?php
/**
* Comment block
* @author: Ross Masters <ross@php.net>
* @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