mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
InputFile now inherits from InputItem
This commit is contained in:
@@ -364,7 +364,7 @@ All object inherits from `InputItem` class and will always contain these methods
|
|||||||
- `getIndex()` - returns the index/key of the input.
|
- `getIndex()` - returns the index/key of the input.
|
||||||
- `getName()` - returns a human friendly name for the input (company_name will be Company Name etc).
|
- `getName()` - returns a human friendly name for the input (company_name will be Company Name etc).
|
||||||
|
|
||||||
`InputFile` has some of the same methods as above along with some other file-specific methods like:
|
`InputFile` has the same methods as above along with some other file-specific methods like:
|
||||||
- `getTmpName()` - get file temporary name.
|
- `getTmpName()` - get file temporary name.
|
||||||
- `getSize()` - get file size.
|
- `getSize()` - get file size.
|
||||||
- `move($destination)` - move file to destination.
|
- `move($destination)` - move file to destination.
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ class Input {
|
|||||||
if(!is_array($value['name'])) {
|
if(!is_array($value['name'])) {
|
||||||
// Strip empty values
|
// Strip empty values
|
||||||
if($value['error'] != '4') {
|
if($value['error'] != '4') {
|
||||||
$file = new InputFile();
|
$file = new InputFile($key);
|
||||||
$file->setIndex($key);
|
|
||||||
$file->setName($value['name']);
|
$file->setName($value['name']);
|
||||||
$file->setSize($value['size']);
|
$file->setSize($value['size']);
|
||||||
$file->setType($value['type']);
|
$file->setType($value['type']);
|
||||||
@@ -172,8 +171,7 @@ class Input {
|
|||||||
foreach($value['name'] as $k=>$val) {
|
foreach($value['name'] as $k=>$val) {
|
||||||
// Strip empty values
|
// Strip empty values
|
||||||
if($value['error'][$k] != '4') {
|
if($value['error'][$k] != '4') {
|
||||||
$file = new InputFile();
|
$file = new InputFile($k);
|
||||||
$file->setIndex($k);
|
|
||||||
$file->setName($value['name'][$k]);
|
$file->setName($value['name'][$k]);
|
||||||
$file->setSize($value['size'][$k]);
|
$file->setSize($value['size'][$k]);
|
||||||
$file->setType($value['type'][$k]);
|
$file->setType($value['type'][$k]);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class InputCollection implements \IteratorAggregate {
|
|||||||
/**
|
/**
|
||||||
* @param $index
|
* @param $index
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return IInputItem
|
* @return InputItem
|
||||||
*/
|
*/
|
||||||
public function __get($index) {
|
public function __get($index) {
|
||||||
$item = $this->findFirst($index);
|
$item = $this->findFirst($index);
|
||||||
|
|||||||
@@ -1,26 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Pecee\Http\Input;
|
namespace Pecee\Http\Input;
|
||||||
|
|
||||||
class InputFile {
|
class InputFile extends InputItem {
|
||||||
|
|
||||||
protected $index;
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $size;
|
protected $size;
|
||||||
protected $type;
|
protected $type;
|
||||||
protected $error;
|
protected $error;
|
||||||
protected $tmpName;
|
protected $tmpName;
|
||||||
|
|
||||||
public function getIndex() {
|
|
||||||
return $this->index;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName() {
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -61,14 +49,6 @@ class InputFile {
|
|||||||
return file_get_contents($this->tmpName);
|
return file_get_contents($this->tmpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setIndex($index) {
|
|
||||||
$this->index = $index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setName($name) {
|
|
||||||
$this->name = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTmpName($name) {
|
public function setTmpName($name) {
|
||||||
$this->tmpName = $name;
|
$this->tmpName = $name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class InputItem {
|
|||||||
protected $name;
|
protected $name;
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
public function __construct($index, $value) {
|
public function __construct($index, $value = null) {
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user