Test Failed
Push — master ( e1ef6d...0e97a6 )
by Alex
01:49
created

AbstractValidator::validateFilesFieldExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 2
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 4
rs 10
1
<?php
2
namespace Mezon\Security\Validators;
3
4
/**
5
 * Class AbstractValidator
6
 *
7
 * @package Mezon
8
 * @subpackage Security
9
 * @author Dodonov A.A.
10
 * @version v.1.0 (2020/05/13)
11
 * @copyright Copyright (c) 2020, aeon.org
12
 */
13
14
/**
15
 * Abstract class for validators
16
 *
17
 * @author gdever
18
 */
19
abstract class AbstractValidator implements ValidatorInterface
20
{
21
22
    /**
23
     * Method validates that $_FILES[$field] exists.
24
     * If it does not then exception will be thrown
25
     *
26
     * @param string $field
27
     *            field name
28
     */
29
    public function validateFilesFieldExists(string $field): void
30
    {
31
        if (isset($_FILES[$field]) === false) {
32
            throw (new \Exception('The index "' . $field . '" was not found in the $_FILES array', - 1));
33
        }
34
    }
35
}