From 55a96a441e259e47d253f4fa7022ff600d4b6a02 Mon Sep 17 00:00:00 2001 From: Simon Sessingo Date: Mon, 19 Feb 2018 23:04:26 +0100 Subject: [PATCH] Set default value to 0 to triggering error when calling getErrors on empty object. --- src/Pecee/Http/Input/InputFile.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Pecee/Http/Input/InputFile.php b/src/Pecee/Http/Input/InputFile.php index 3f7d51b..9633c3f 100644 --- a/src/Pecee/Http/Input/InputFile.php +++ b/src/Pecee/Http/Input/InputFile.php @@ -9,13 +9,15 @@ class InputFile implements IInputItem public $filename; public $size; public $type; - public $error; + public $errors; public $tmpName; public function __construct($index) { $this->index = $index; + $this->errors = 0; + // Make the name human friendly, by replace _ with space $this->name = ucfirst(str_replace('_', ' ', strtolower($this->index))); } @@ -216,7 +218,7 @@ class InputFile implements IInputItem */ public function getError() { - return $this->error; + return $this->errors; } /** @@ -227,7 +229,7 @@ class InputFile implements IInputItem */ public function setError($error) { - $this->error = (int)$error; + $this->errors = (int)$error; return $this; } @@ -269,7 +271,7 @@ class InputFile implements IInputItem 'type' => $this->type, 'size' => $this->size, 'name' => $this->name, - 'error' => $this->error, + 'error' => $this->errors, 'filename' => $this->filename, ]; }