diff --git a/src/Upload_Validator.php b/src/Upload_Validator.php index 5a25e739..774ec87e 100644 --- a/src/Upload_Validator.php +++ b/src/Upload_Validator.php @@ -75,19 +75,28 @@ public function getErrors() /** * Clear out all errors + * + * @return $this */ public function clearErrors() { $this->errors = []; + + return $this; } /** * Set information about temporary file produced by PHP. + * * @param array $tmpFile + * + * @return $this */ public function setTmpFile($tmpFile) { $this->tmpFile = $tmpFile; + + return $this; } @@ -154,6 +163,8 @@ public function getAllowedMaxFileSize($ext = null) * * * @param array|int|string $rules + * + * @return $this */ public function setAllowedMaxFileSize($rules) { @@ -178,6 +189,8 @@ public function setAllowedMaxFileSize($rules) } elseif ((int)$rules > 0) { $this->allowedMaxFileSize['*'] = (int)$rules; } + + return $this; } /** @@ -196,6 +209,8 @@ public function getAllowedExtensions() * See {@link setAllowedMaxFileSize()} to limit file size by extension. * * @param array $rules List of extensions + * + * @return $this */ public function setAllowedExtensions($rules) { @@ -209,6 +224,8 @@ public function setAllowedExtensions($rules) } $this->allowedExtensions = $rules; + + return $this; } /** diff --git a/tests/php/UploadValidatorTest.php b/tests/php/UploadValidatorTest.php new file mode 100644 index 00000000..f677412b --- /dev/null +++ b/tests/php/UploadValidatorTest.php @@ -0,0 +1,29 @@ +clearErrors()->setAllowedMaxFileSize(100)->setAllowedExtensions([ + 'jpg' + ]); + + $this->assertInstanceOf(Upload_Validator::class, $chain); + } +}