Completed
Push — master ( f42a52...0a9499 )
by Thierry
02:50 queued 01:16
created

Validator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 73
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 3

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getValidatorMessage() 0 4 1
A validateFunction() 0 4 1
A validateEvent() 0 4 1
A validateClass() 0 4 1
A validateMethod() 0 4 1
A validateUploadedFile() 0 4 1
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\Features;
14
15
trait Validator
16
{
17
    /**
18
     * Get the last error message
19
     *
20
     * @return string          The last error message
21
     */
22
    public function getValidatorMessage()
23
    {
24
        return jaxon()->di()->getValidator()->getErrorMessage();
25
    }
26
27
    /**
28
     * Validate a function name
29
     *
30
     * @param string        $sName            The function name
31
     *
32
     * @return bool            True if the function name is valid, and false if not
33
     */
34
    public function validateFunction($sName)
35
    {
36
        return jaxon()->di()->getValidator()->validateFunction($sName);
37
    }
38
39
    /**
40
     * Validate an event name
41
     *
42
     * @param string        $sName            The event name
43
     *
44
     * @return bool            True if the event name is valid, and false if not
45
     */
46
    public function validateEvent($sName)
47
    {
48
        return jaxon()->di()->getValidator()->validateEvent($sName);
49
    }
50
51
    /**
52
     * Validate a class name
53
     *
54
     * @param string        $sName            The class name
55
     *
56
     * @return bool            True if the class name is valid, and false if not
57
     */
58
    public function validateClass($sName)
59
    {
60
        return jaxon()->di()->getValidator()->validateClass($sName);
61
    }
62
63
    /**
64
     * Validate a method name
65
     *
66
     * @param string        $sName            The function name
67
     *
68
     * @return bool            True if the method name is valid, and false if not
69
     */
70
    public function validateMethod($sName)
71
    {
72
        return jaxon()->di()->getValidator()->validateMethod($sName);
73
    }
74
75
    /**
76
     * Validate an uploaded file
77
     *
78
     * @param string        $sName            The uploaded file variable name
79
     * @param array         $aUploadedFile    The file data received in the $_FILES array
80
     *
81
     * @return bool            True if the file data are valid, and false if not
82
     */
83
    public function validateUploadedFile($sName, array $aUploadedFile)
84
    {
85
        return jaxon()->di()->getValidator()->validateUploadedFile($sName, $aUploadedFile);
86
    }
87
}
88