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

AbstractValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

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
}