Modified detect of empty data in File.getInstance(). Add SIZE_INSTRUCTION into Image class.

This commit is contained in:
Alexander Demidov
2013-05-29 13:29:03 +04:00
parent 4ace9e1b02
commit 47e20b1ef8
2 changed files with 5 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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,