Type   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validate() 0 12 3
1
<?php
2
3
/**
4
 * Type validator
5
 *
6
 * @category    Venus
7
 * @package     Venus\lib\Validator
8
 * @author      Judicaël Paquet <[email protected]>
9
 * @copyright   Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
10
 * @license     https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
11
 * @version     Release: 1.0.0
12
 * @filesource  https://github.com/las93/venus2
13
 * @link        https://github.com/las93
14
 * @since       1.0
15
 */
16
namespace Venus\lib\Validator;
17
18
/**
19
 * Type validator
20
 *
21
 * @category    Venus
22
 * @package     Venus\lib\Validator
23
 * @author      Judicaël Paquet <[email protected]>
24
 * @copyright   Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
25
 * @license     https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
26
 * @version     Release: 1.0.0
27
 * @filesource  https://github.com/las93/venus2
28
 * @link        https://github.com/las93
29
 * @since       1.0
30
 */
31
class Type extends Common
32
{
33
    /**
34
     * type
35
     * @var type
36
     */
37
    private $_sType = '';
38
    
39
    /**
40
     * constructor
41
     *
42
     * @access public
43
     * @param  string $sType type
44
     * @return Type
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
45
     */
46
    public function __construct(string $sType)
47
    {
48
        $this->_sType = $sType;
0 ignored issues
show
Documentation Bug introduced by
It seems like $sType of type string is incompatible with the declared type object<Venus\lib\Validator\Type> of property $_sType.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
49
    }
50
    
51
    /**
52
     * validate the Type
53
     *
54
     * @access public
55
     * @param  string $sValue
56
     * @return bool
57
     */
58
    public function validate(string $sValue = null) : bool
59
    {
60
        if ($this->_sType == 'DateTime') {
61
            
62
            if (preg_match('#^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}#', $sValue)) {
63
                
64
                return true;
65
            }
66
        }
67
        
68
        return false;
69
    }
70
}
71