mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-16 10:40:18 +03:00
Development
- Fixed updatae causing middlewares to sometimes load on wrong routes. - Converted project to PSR/2. - Updated InputCollection class and added get method for easy access to values. - Complete refactor of RouterBase. - Added findRoute method to RouterBase. - It's now possible to change parameter modifiers and symbol by overwriting properties on RouterBase. - Added RouterUrlTest unit-test for testing route-urls. - Added IRestController that can be easily implemented in custom ResourceController-classes. - It's now possible to use "-" instead of "_" when using getHeader method in Request class. - Added PHPDocs. - Fixed "/" route sometimes returning "//" as url. - Optimisations and bugfixes.
This commit is contained in:
@@ -1,68 +1,109 @@
|
||||
<?php
|
||||
namespace Pecee\Http\Input;
|
||||
|
||||
class InputFile extends InputItem {
|
||||
|
||||
protected $name;
|
||||
protected $size;
|
||||
protected $type;
|
||||
protected $error;
|
||||
protected $tmpName;
|
||||
class InputFile extends InputItem
|
||||
{
|
||||
public $size;
|
||||
public $type;
|
||||
public $error;
|
||||
public $tmpName;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSize() {
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType() {
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getError() {
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getMime()
|
||||
{
|
||||
return $this->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTmpName() {
|
||||
public function getTmpName()
|
||||
{
|
||||
return $this->tmpName;
|
||||
}
|
||||
|
||||
public function getExtension() {
|
||||
public function getExtension()
|
||||
{
|
||||
return pathinfo($this->getName(), PATHINFO_EXTENSION);
|
||||
}
|
||||
}
|
||||
|
||||
public function move($destination) {
|
||||
public function move($destination)
|
||||
{
|
||||
return move_uploaded_file($this->tmpName, $destination);
|
||||
}
|
||||
|
||||
public function getContents() {
|
||||
public function getContents()
|
||||
{
|
||||
return file_get_contents($this->tmpName);
|
||||
}
|
||||
|
||||
public function setTmpName($name) {
|
||||
$this->tmpName = $name;
|
||||
}
|
||||
public function setTmpName($name)
|
||||
{
|
||||
$this->tmpName = $name;
|
||||
}
|
||||
|
||||
public function setSize($size) {
|
||||
$this->size = $size;
|
||||
}
|
||||
public function setSize($size)
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
public function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setError($error) {
|
||||
$this->error = $error;
|
||||
}
|
||||
public function setError($error)
|
||||
{
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create from array
|
||||
* @param array $values
|
||||
* @return static
|
||||
*/
|
||||
public static function createFromArray(array $values)
|
||||
{
|
||||
if(!isset($values['index'])) {
|
||||
throw new \InvalidArgumentException('Index key is required');
|
||||
}
|
||||
|
||||
$input = new static($values['index']);
|
||||
$input->setTmpName((isset($values['error']) ? $values['error'] : null));
|
||||
$input->setName((isset($values['name']) ? $values['name'] : null));
|
||||
$input->setSize((isset($values['size']) ? $values['size'] : null));
|
||||
$input->setType((isset($values['type']) ? $values['type'] : null));
|
||||
$input->setError((isset($values['tmp_name']) ? $values['tmp_name'] : null));
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return (string)$this->tmpName;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user