diff --git a/File.class.php b/File.class.php index 4efebe2..81d2d05 100644 --- a/File.class.php +++ b/File.class.php @@ -11,7 +11,16 @@ abstract class File { public $path; + public $filename; + + public $logger; + + public function __construct() + { + $this->logger = Logger::getInstance(); + } + /** * @param array|string|null $data * @return Image @@ -24,8 +33,7 @@ abstract class File if (!is_array($data)) { $data = json_decode($data, true); if (json_last_error() != JSON_ERROR_NONE) { - //TODO: подумать над тем, чтобы субмодуль не был связан с классом приложения - вынести отдельно логгер для этого класса - ErrorMessage::log('Unable to convert json-string to array. Data ' . print_r($data, true)); + $instance->logger->log('Unable to convert json-string to array. Data ' . print_r($data, true)); } } if (is_array($data)) { diff --git a/UploadHelper.class.php b/UploadHelper.class.php index 3251dd7..e0e2929 100644 --- a/UploadHelper.class.php +++ b/UploadHelper.class.php @@ -41,4 +41,20 @@ abstract class UploadHelper } return false; } + + /** + * @param $size + * @param $file_path + * @return bool + */ + public static function imageCheckMinSize($size, $file_path) + { + $imagesize = getimagesize($file_path); + $size_parts = explode('x', $size); + if ($imagesize[0] >= $size_parts[0] && $imagesize[1] >= $size_parts[1]) { + return true; + } else { + return false; + } + } } \ No newline at end of file