Browse Source

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

master
Alexander Demidov 11 years ago
parent
commit
47e20b1ef8
  1. 6
      File.class.php
  2. 3
      Image.class.php

6
File.class.php

@ -12,8 +12,8 @@ abstract class File
public static function getInstance($data) public static function getInstance($data)
{ {
$instance = new static($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)) { if (!is_array($data)) {
$data = json_decode($data, true); $data = json_decode($data, true);
@ -22,7 +22,7 @@ abstract class File
} }
} }
foreach ($data as $attribute_name => $attribute_value) { foreach ($data as $attribute_name => $attribute_value) {
if (property_exists(__CLASS__, $attribute_name)) {
if (property_exists($instance, $attribute_name)) {
$instance->{$attribute_name} = $attribute_value; $instance->{$attribute_name} = $attribute_value;
} }
} }

3
Image.class.php

@ -14,7 +14,8 @@ class Image extends File
const SIZE_200_160 = '200x160'; const SIZE_200_160 = '200x160';
const SIZE_300_240 = '300x240'; const SIZE_300_240 = '300x240';
const SIZE_550_440 = '550x440'; const SIZE_550_440 = '550x440';
const SIZE_SKI = '1000x';
const SIZE_SKI = 'x';
const SIZE_INSTRUCTION = 'x';
public static $sizes = array( public static $sizes = array(
self::SIZE_100_80, self::SIZE_100_80,

Loading…
Cancel
Save