Re: PHP Brain Teasers
| From: | Jochem Maas | Date: | Wed, 27 Jun 2007 09:00:12 +0000 |
| Subject: | Re: PHP Brain Teasers | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257838@lists.php.net to get a copy of this message | ||
Daniel Brown wrote:
> What the hell? Why not start a thread that can be fun and
... here's a easy one:
interface Currency {}
interface Employee {}
class Peanut implements Currency {}
class Primate implements Employee {}
abstract class HeadHunter {
static function match(Currency $c) {
if ($c instanceof Peanut) return new Primate;
throw new Exception("never heard of outsourcing?");
}
}
try {
echo get_class(HeadHunter::match(new Peanut)),"\n";
} catch (Exception $e) { echo $e->getMessage(),"\n"; }