Barneys Version

 <?php
class Actor {
    private $name;
    private $text;
   
    public function __construct($name, $text) {
        $this->name = $name;
        $this->text = $text;
    }
   
    public function __get($what) {
        switch($what) {
            case 'version':
                return $this->name. ': '. $this->text;
            case 'name':
                return $this->name;
        }
    }
}

class Movie {
    private $cast = array();
   
    public function __construct() {    
        $this->cast[] = new Actor('Barney', 'We were drunk. I fired in the air twice. I stumbled. Hit my head. Passed away. I woke up. He was gone.');
    }
   
    public function getActor($name) {
        foreach($this->cast as $cast) {
            if($cast->name == $name) {
                return $cast;
            }
        }        
    }
}

$Movie = new Movie();

print $Movie->getActor('Barney')->version;
?>
Vote up this code7