From 47e20b1ef8ff346184cb05895c00c63c03c590ff Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Wed, 29 May 2013 13:29:03 +0400 Subject: [PATCH] Modified detect of empty data in File.getInstance(). Add SIZE_INSTRUCTION into Image class. --- File.class.php | 6 +++--- Image.class.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/File.class.php b/File.class.php index e44028b..25ebabe 100644 --- a/File.class.php +++ b/File.class.php @@ -12,8 +12,8 @@ abstract class File public static function getInstance($data) { $instance = new static($data); - if (is_null($data)) { - throw new ErrorException('Empty data for Image::getInstance().'); + if (is_null($data) || $data == '') { + throw new ErrorException('Empty data for File::getInstance().'); } if (!is_array($data)) { $data = json_decode($data, true); @@ -22,7 +22,7 @@ abstract class File } } foreach ($data as $attribute_name => $attribute_value) { - if (property_exists(__CLASS__, $attribute_name)) { + if (property_exists($instance, $attribute_name)) { $instance->{$attribute_name} = $attribute_value; } } diff --git a/Image.class.php b/Image.class.php index b4093d5..194639b 100644 --- a/Image.class.php +++ b/Image.class.php @@ -14,7 +14,8 @@ class Image extends File const SIZE_200_160 = '200x160'; const SIZE_300_240 = '300x240'; const SIZE_550_440 = '550x440'; - const SIZE_SKI = '1000x'; + const SIZE_SKI = 'x'; + const SIZE_INSTRUCTION = 'x'; public static $sizes = array( self::SIZE_100_80,