Classi per la configurazione upload
Cristiano Magro
2019-07-09 2421604aa16e3f953cc61bcfe228c5b6314685b0
src/Vola/UploadFile/SetupUpload.class.php
@@ -9,7 +9,8 @@
 *
 * @author Cristiano Magro
 */
class SetupUpload {
class SetupUpload
{
    private $queueLimitUpload;
    private $totLimitUpload;
@@ -28,30 +29,36 @@
     *
     * @return \SetupUpload
     */
    public static function create() {
    public static function create()
    {
        $instance = new self;
        return $instance;
    }
    public function getQueueLimit() {
    public function getQueueLimit()
    {
        return $this->queueLimitUpload;
    }
    public function setQueueLimit($x) {
    public function setQueueLimit($x)
    {
        $this->queueLimitUpload = $x;
        return $this;
    }
    public function getTotalLimit() {
    public function getTotalLimit()
    {
        return $this->totLimitUpload;
    }
    public function setTotalLimit($x) {
    public function setTotalLimit($x)
    {
        $this->totLimitUpload = $x;
        return $this;
    }
    public function getSizeLimitFile() {
    public function getSizeLimitFile()
    {
        return $this->sizeLimitFileUpload;
    }
@@ -65,39 +72,47 @@
     *
     * @return \SetupUpload
     */
    public function setSizeLimitFile($x) {
    public function setSizeLimitFile($x)
    {
        $this->sizeLimitFileUpload = self::str2Bytes($x);
        return $this;
    }
    public function getLimitText() {
    public function getLimitText()
    {
        return $this->totLimitUploadTest;
    }
    public function setLimitText($x) {
    public function setLimitText($x)
    {
        $this->totLimitUploadTest = $x;
        return $this;
    }
    public function getFilesFilter() {
    public function getFilesFilter()
    {
        return $this->fileFilterExt;
    }
    public function setFilesFilter($x) {
    public function setFilesFilter($x)
    {
        $this->fileFilterExt = $x;
        return $this;
    }
    public function getRandomValue() {
    public function getRandomValue()
    {
        return $this->random;
    }
    public function setRandomValue($x) {
    public function setRandomValue($x)
    {
        $this->random = $x;
        return $this;
    }
    public function getPathUploadKey() {
    public function getPathUploadKey()
    {
        return $this->pathUploadKey;
    }
@@ -112,7 +127,8 @@
     *
     * @return \SetupUpload
     */
    public function setPathUploadKey($pathKey) {
    public function setPathUploadKey($pathKey)
    {
        $this->pathUploadKey = $pathKey;
        return $this;
    }
@@ -122,7 +138,8 @@
     *
     * @return integer Max numero file
     */
    public function getNumMaxFiles() {
    public function getNumMaxFiles()
    {
        return $this->numMaxFiles;
    }
@@ -130,10 +147,10 @@
     * Viene impostato il numero massimo di file caricabili
     *
     * @param integer $numero limite massimo file caricabili
     *
     * @return \SetupUpload fluent style
     */
    public function setNumMaxFiles($numero) {
    public function setNumMaxFiles($numero)
    {
        if (!is_integer($numero) || $numero <= 0) {
            throw new Upload_Exc_Error();
        }
@@ -142,7 +159,8 @@
        return $this;
    }
    public function getSizeMaxFilesByte() {
    public function getSizeMaxFilesByte()
    {
        return $this->sizeMaxFilesByte;
    }
@@ -156,26 +174,39 @@
     *
     * @return \SetupUpload
     */
    public function setSizeMaxFilesByte($x) {
    public function setSizeMaxFilesByte($x)
    {
        $this->sizeMaxFilesByte = self::str2Bytes($x);
        return $this;
    }
    public function getSizeMaxFilesDesc() {
    public function getSizeMaxFilesDesc()
    {
        return $this->sizeMaxFilesDesc;
    }
    public function setSizeMaxFilesDesc($x) {
    public function setSizeMaxFilesDesc($x)
    {
        $this->sizeMaxFilesDesc = $x;
        return $this;
    }
    public function getDebugActive() {
    /**
     * @return bool
     */
    public function getDebugActive()
    {
        return $this->debugPageActive;
    }
    public function setDebugActive($x) {
        $this->debugPageActive = $x;
    /**
     * @param bool $value
     * @return $this
     */
    public function setDebugActive($value)
    {
        $this->debugPageActive = $value;
        return $this;
    }
@@ -188,7 +219,8 @@
     *
     * @return string json
     */
    public function createJsonSetup() {
    public function createJsonSetup()
    {
        $dati = array(
            'QUEUE_LIMIT_UPLOAD' => $this->getQueueLimit(),
            'TOT_LIMIT_UPLOAD' => $this->getSizeMaxFilesByte(),
@@ -206,12 +238,11 @@
     * 1 Mb = 1024^2
     *
     * @param string $strSize Stringa da convertire
     *
     * @throws UploadFile_Excs
     *
     * @return integer
     */
    public static function str2Bytes($strSize) {
    public static function str2Bytes($strSize)
    {
        $Units = array('b' => 0, 'kb' => 1, 'mb' => 2, 'gb' => 3, 'tb' => 4);
        $strUnit = strtolower($strSize);