updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -9,13 +9,15 @@
namespace Zend\Validator\File;
use Zend\Validator\Exception;
use Zend\Validator\File\FileInformationTrait;
/**
* Validator for the crc32 hash of given files
*/
class Crc32 extends Hash
{
use FileInformationTrait;
/**
* @const string Error constants
*/
@@ -85,32 +87,18 @@ class Crc32 extends Hash
*/
public function isValid($value, $file = null)
{
if (is_string($value) && is_array($file)) {
// Legacy Zend\Transfer API support
$filename = $file['name'];
$file = $file['tmp_name'];
} elseif (is_array($value)) {
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
);
}
$file = $value['tmp_name'];
$filename = $value['name'];
} else {
$file = $value;
$filename = basename($file);
}
$this->setValue($filename);
$fileInfo = $this->getFileInfo($value, $file);
$this->setValue($fileInfo['filename']);
// Is file readable ?
if (empty($file) || false === is_readable($file)) {
if (empty($fileInfo['file']) || false === is_readable($fileInfo['file'])) {
$this->error(self::NOT_FOUND);
return false;
}
$hashes = array_unique(array_keys($this->getHash()));
$filehash = hash_file('crc32', $file);
$filehash = hash_file('crc32', $fileInfo['file']);
if ($filehash === false) {
$this->error(self::NOT_DETECTED);
return false;