CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS^25class Image_PNG implements IImage {private $_width, $_height, $_data;public function __construct($file) {
$this->_file = $file;
$this->_parse();
}private function _parse() {
//Complete PNG specific parsing
//and populate $_width, $_height and $_data
}public function getWidth() {
return $this->_width;
}public function getHeight() {
return $this->_height;
}public function getData() {
return $this->_data;
}}class Image_JPEG implements IImage {private $_width, $_height, $_data;public function __construct($file) {
$this->_file = $file;
$this->_parse();
}private function _parse() {
//Complete JPEG specific parsing
//and populate $_width, $_height and $_data
}public function getWidth() {
return $this->_width;
}McArthur_819-9C03.fm Page 25 Friday, February 1, 2008 10:24 AM