Edit File: File.inc
<?php namespace B2\Entities; class File { private $_data; private function _set($key, $val){ $this->_data[$key] = $val; } private function _get($key, $default=null) {return isset($this->_data[$key]) ? $this->_data[$key] : $default; } const FIELD_ID = "fileId", FIELD_NAME = "fileName", FIELD_HASH = "contentSha1", FIELD_SIZE = "size", FIELD_CONTENT_LENFTH = "contentLength", FIELD_TYPE = "contentType", FIELD_INFO = "fileInfo", FIELD_BUCKET_ID = "backetId", FIELD_ACTION = "action", FIELD_UPLOAD_TIMESTAMP = "uploadTimestamp"; /** * Constructor */ public function __construct($data=[]) { $this->setData($data); } /** * * @param array $data */ public function setData($data){ $this->_data = $data; } /** * @return string */ public function getId() { return $this->_get(self::FIELD_ID); } /** * * @param string $id */ public function setId($id) { $this->_set(self::FIELD_ID, $id ); } /** * @return string */ public function getName() { return $this->_get(self::FIELD_NAME); } /** * * @param string $name */ public function setName($name) { $this->_set(self::FIELD_NAME, $name ); } /** * @return string */ public function getHash() { return $this->_get(self::FIELD_HASH); } /** * * @param string $hash */ public function setHash($hash) { $this->_set(self::FIELD_HASH, $hash ); } /** * @return int */ public function getSize() { return $this->_get(self::FIELD_SIZE, $this->getContentLength()); } /** * * @param int $size */ public function setSize($size) {$this->_set(self::FIELD_SIZE, $size); } /** * @return string contnet type */ public function getType() { return $this->_get(self::FIELD_TYPE, $this->getContentLength() ); } /** * * @param int $size */ public function setContentLength($len) {$this->_set(self::FIELD_CONTENT_LENFTH, $len); } /** * @return string contnet type */ public function getContentLength() { return $this->_get(self::FIELD_CONTENT_LENFTH); } /** * * @param string $type contnet type */ public function setType($type) {$this->_set(self::FIELD_TYPE, $type); } /** * @return array */ public function getInfo() { return $this->_get(self::FIELD_INFO); } /** * * @param array $info */ public function setInfo($info) {$this->_set(self::FIELD_INFO, $info); } /** * @return string */ public function getAction() { return $this->_get(self::FIELD_ACTION); } /** * * @param string $action */ public function setAction($action) { $this->_set(self::FIELD_ACTION, $action); } /** * @return string */ public function getUploadTimestamp() { return $this->_get(self::FIELD_UPLOAD_TIMESTAMP); } /** * * @param number $timestamp */ public function setUploadTimestamp($timestamp) { $this->_set(self::FIELD_UPLOAD_TIMESTAMP, $timestamp); } /** * * @return boolean */ public function isFile() { return $this->getAction() == "upload"; } /** * * @return boolean */ public function isFolder() { return $this->getAction() == "folder"; } }