InputFile now inherits from InputItem

This commit is contained in:
Simon Sessingø
2016-04-15 23:10:49 +02:00
parent 17adfb8aa4
commit 7fdeef74d6
5 changed files with 6 additions and 28 deletions
+2 -4
View File
@@ -155,8 +155,7 @@ class Input {
if(!is_array($value['name'])) {
// Strip empty values
if($value['error'] != '4') {
$file = new InputFile();
$file->setIndex($key);
$file = new InputFile($key);
$file->setName($value['name']);
$file->setSize($value['size']);
$file->setType($value['type']);
@@ -172,8 +171,7 @@ class Input {
foreach($value['name'] as $k=>$val) {
// Strip empty values
if($value['error'][$k] != '4') {
$file = new InputFile();
$file->setIndex($k);
$file = new InputFile($k);
$file->setName($value['name'][$k]);
$file->setSize($value['size'][$k]);
$file->setType($value['type'][$k]);
+1 -1
View File
@@ -32,7 +32,7 @@ class InputCollection implements \IteratorAggregate {
/**
* @param $index
* @throws \InvalidArgumentException
* @return IInputItem
* @return InputItem
*/
public function __get($index) {
$item = $this->findFirst($index);
+1 -21
View File
@@ -1,26 +1,14 @@
<?php
namespace Pecee\Http\Input;
class InputFile {
class InputFile extends InputItem {
protected $index;
protected $name;
protected $size;
protected $type;
protected $error;
protected $tmpName;
public function getIndex() {
return $this->index;
}
/**
* @return string
*/
public function getName() {
return $this->name;
}
/**
* @return string
*/
@@ -61,14 +49,6 @@ class InputFile {
return file_get_contents($this->tmpName);
}
public function setIndex($index) {
$this->index = $index;
}
public function setName($name) {
$this->name = $name;
}
public function setTmpName($name) {
$this->tmpName = $name;
}
+1 -1
View File
@@ -7,7 +7,7 @@ class InputItem {
protected $name;
protected $value;
public function __construct($index, $value) {
public function __construct($index, $value = null) {
$this->index = $index;
$this->value = $value;