Definition at line 35 of file Hash.php.
◆ __construct()
Sets validator options
- Parameters
-
- Exceptions
-
Definition at line 66 of file Hash.php.
73 #require_once 'Zend/Validate/Exception.php'; 77 if (1 < func_num_args()) {
78 $options[
'algorithm'] = func_get_arg(1);
elseif(isset( $params[ 'redirect_parent']))
◆ _throw()
_throw |
( |
|
$file, |
|
|
|
$errorType |
|
) |
| |
|
protected |
Throws an error of the given type
- Parameters
-
string | $file | |
string | $errorType | |
- Returns
- false
Definition at line 186 of file Hash.php.
188 if ($file !==
null) {
189 $this->_value = $file[
'name'];
192 $this->
_error($errorType);
_error($messageKey, $value=null)
◆ addHash()
Adds the hash for one or multiple files
- Parameters
-
- Exceptions
-
- Returns
- Zend_Validate_File_Hash Provides a fluent interface
Definition at line 115 of file Hash.php.
120 #require_once 'Zend/Validate/Exception.php'; 124 $known = hash_algos();
125 if (!isset(
$options[
'algorithm'])) {
126 $algorithm =
'crc32';
132 if (!in_array($algorithm, $known)) {
133 #require_once 'Zend/Validate/Exception.php'; 138 $this->_hash[
$value] = $algorithm;
◆ getHash()
Returns the set hash values as array, the hash as key and the algorithm the value
- Returns
- array
Definition at line 89 of file Hash.php.
◆ isValid()
isValid |
( |
|
$value, |
|
|
|
$file = null |
|
) |
| |
Defined by Zend_Validate_Interface
Returns true if and only if the given file confirms the set hash
- Parameters
-
- Returns
- boolean
Definition at line 153 of file Hash.php.
156 #require_once 'Zend/Loader.php'; 158 return $this->
_throw($file, self::NOT_FOUND);
161 $algos = array_unique(array_values($this->_hash));
162 $hashes = array_unique(array_keys($this->_hash));
163 foreach ($algos as $algorithm) {
164 $filehash = hash_file($algorithm,
$value);
165 if ($filehash ===
false) {
166 return $this->
_throw($file, self::NOT_DETECTED);
169 foreach($hashes as $hash) {
170 if ($filehash === $hash) {
176 return $this->
_throw($file, self::DOES_NOT_MATCH);
static isReadable($filename)
_throw($file, $errorType)
◆ setHash()
◆ $_hash
◆ $_messageTemplates
Initial value:= array(
self::DOES_NOT_MATCH => "File '%value%' does not match the given hashes",
self::NOT_DETECTED => "A hash could not be evaluated for the given file",
self::NOT_FOUND => "File '%value%' is not readable or does not exist"
)
Definition at line 47 of file Hash.php.
◆ DOES_NOT_MATCH
const DOES_NOT_MATCH = 'fileHashDoesNotMatch' |
@const string Error constants
Definition at line 40 of file Hash.php.
◆ NOT_DETECTED
const NOT_DETECTED = 'fileHashHashNotDetected' |
◆ NOT_FOUND
const NOT_FOUND = 'fileHashNotFound' |
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Validate/File/Hash.php