Skip to content

Instantly share code, notes, and snippets.

@fabioluciano
Created September 13, 2011 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabioluciano/1215510 to your computer and use it in GitHub Desktop.
Save fabioluciano/1215510 to your computer and use it in GitHub Desktop.
<?php
class Convert_Abstraction_AbstractFactory {
public function __construct() {
}
public static function convert($to) {
require_once('Convert_Abstraction_Factory.php');
switch ($to) {
case 'png':
require_once 'Convert_Abstraction_Factory_PNG.php';
$factory = new Abstract_Factory_Convert_PNG();
break;
case 'jpg':
require_once 'Convert_Abstraction_Factory_JPG.php';
$factory = new Abstract_Factory_Convert_JPG();
break;
}
return $factory;
}
}
$abstractfactory = new Convert_Abstraction_AbstractFactory();
$factory = $abstractfactory::convert('png');
$factory->image_convert('jpg.jpg');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment