Created
November 14, 2013 18:21
-
-
Save mnapoli/7471722 to your computer and use it in GitHub Desktop.
Factory methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Image | |
{ | |
private $width; | |
private $height; | |
private $content; | |
public static function createEmpty($width, $height, $bgcolor = null) | |
{ | |
$image = new Image(); | |
$image->width = $width; | |
$image->height = $height; | |
$image->content = …; | |
return $image; | |
} | |
public static function createFromFile($file) | |
{ | |
$reader = new FileReader($file); | |
return self::createFromString($file->getContent()); | |
} | |
public static function createFromString($str) | |
{ | |
$image = new Image(); | |
$image->width = $width; | |
$image->height = $height; | |
$image->content = …; | |
return $image; | |
} | |
private function __construct() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment