Completed
Push — master ( f10304...059713 )
by Thierry
02:01
created

Validator::validateUploadedFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
/**
4
 * Validator.php - Trait for validation functions
5
 *
6
 * @package jaxon-core
7
 * @author Thierry Feuzeu <[email protected]>
8
 * @copyright 2016 Thierry Feuzeu <[email protected]>
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
10
 * @link https://github.com/jaxon-php/jaxon-core
11
 */
12
13
namespace Jaxon\Utils\Traits;
14
15
use Jaxon\Utils\Container;
16
17
trait Validator
18
{
19
    /**
20
     * Get the last error message
21
     *
22
     * @return string          The last error message
23
     */
24
    public function getValidatorMessage()
25
    {
26
        return Container::getInstance()->getValidator()->getErrorMessage();
27
    }
28
29
    /**
30
     * Validate a function name
31
     *
32
     * @param string        $sName            The function name
33
     *
34
     * @return bool            True if the function name is valid, and false if not
35
     */
36
    public function validateFunction($sName)
37
    {
38
        return Container::getInstance()->getValidator()->validateFunction($sName);
39
    }
40
41
    /**
42
     * Validate an event name
43
     *
44
     * @param string        $sName            The event name
45
     *
46
     * @return bool            True if the event name is valid, and false if not
47
     */
48
    public function validateEvent($sName)
49
    {
50
        return Container::getInstance()->getValidator()->validateEvent($sName);
51
    }
52
53
    /**
54
     * Validate a class name
55
     *
56
     * @param string        $sName            The class name
57
     *
58
     * @return bool            True if the class name is valid, and false if not
59
     */
60
    public function validateClass($sName)
61
    {
62
        return Container::getInstance()->getValidator()->validateClass($sName);
63
    }
64
65
    /**
66
     * Validate a method name
67
     *
68
     * @param string        $sName            The function name
69
     *
70
     * @return bool            True if the method name is valid, and false if not
71
     */
72
    public function validateMethod($sName)
73
    {
74
        return Container::getInstance()->getValidator()->validateMethod($sName);
75
    }
76
77
    /**
78
     * Validate an uploaded file
79
     *
80
     * @param string        $sName            The uploaded file variable name
81
     * @param array         $aUploadedFile    The file data received in the $_FILES array
82
     *
83
     * @return bool            True if the file data are valid, and false if not
84
     */
85
    public function validateUploadedFile($sName, array $aUploadedFile)
86
    {
87
        return Container::getInstance()->getValidator()->validateUploadedFile($sName, $aUploadedFile);
88
    }
89
}
90