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