<?php
|
/**
|
* Created by PhpStorm.
|
* User: Cristiano Magro
|
* Date: 16/01/2018
|
* Time: 16:57
|
* @package Plupload
|
* @since v0.3.2
|
*/
|
|
/**
|
* Class Upload_FileUp manipolazione dettagli file caricato dagestire.
|
*
|
* Si tratta di un wrapper per gestire il file appena caricato.
|
*
|
*/
|
class Upload_FileUp
|
{
|
|
const EMPTY_OBJ = "vuoto";
|
|
private $request;
|
private $beanFile;
|
public static function create()
|
{
|
$instance = new self();
|
$instance->request = new stdClass();
|
$instance->beanFile = new stdClass();
|
return $instance;
|
}
|
|
public function __toString()
|
{
|
return $this->toString();
|
}
|
|
/**
|
* Creo una stringa della struttura interna per la stampa sul logger.
|
*
|
* @return mixed|string struttura interna per il log
|
*/
|
public function toString()
|
{
|
$text = "Richiesta: " . $this->convertToString($this->request) . PHP_EOL;
|
$text .= "Bean: " . $this->convertToString($this->beanFile);
|
return $text;
|
}
|
|
/**
|
* Converto la struttura in una stringa per la stamapa.
|
*
|
* Se la struttura e' vuota ritorno "vuota"
|
* @param stdClass $data struttura dati
|
* @return string conversione della struttura
|
*/
|
private function convertToString(stdClass $data)
|
{
|
//effettuo il cast ad array per testare se la classe e' vuota
|
$tmp = (array)$data;
|
if (empty($tmp)) {
|
return self::EMPTY_OBJ;
|
} else {
|
return print_r($data, true);
|
}
|
}
|
|
|
}
|