AbstractValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 3
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateFilesFieldExists() 0 4 2
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
}