Completed
Push — master ( b109a3...ad6b2e )
by Bálint
03:25
created

NullType::getTypeCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace POData\Providers\Metadata\Type;
4
5
use POData\Common\NotImplementedException;
6
7
/**
8
 * Class NullType
9
 * @package POData\Providers\Metadata\Type
10
 */
11
class NullType implements IType
12
{
13
    /**
14
     * Gets the type code
15
     * Note: implementation of IType::getTypeCode
16
     *   
17
     * @return TypeCode
18
     */
19
    public function getTypeCode()
20
    {
21
        return TypeCode::NULL1;
22
    }
23
24
    /**
25
     * Checks this type (Null) is compatible with another type
26
     * Note: implementation of IType::isCompatibleWith
27
     * 
28
     * @param IType $type Type to check compatibility
29
     * 
30
     * @return boolean 
31
     */
32
    public function isCompatibleWith(IType $type)
33
    {
34
        throw new NotImplementedException();
35
    }
36
37
    /**
38
     * Validate a value in Astoria uri is in a format for this type
39
     * Note: implementation of IType::validate
40
     * 
41
     * @param string $value     The value to validate 
42
     * @param string &$outValue The stripped form of $value that can 
43
     *                          be used in PHP expressions
44
     * 
45
     * @return boolean
46
     */
47 View Code Duplication
    public function validate($value, &$outValue)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        if (strcmp($value, 'null') != 0) {
50
            return false;
51
        }
52
        
53
        $outValue = $value;
54
        return true;
55
    }
56
57
    /**
58
     * Gets full name of this type in EDM namespace
59
     * Note: implementation of IType::getFullTypeName
60
     * 
61
     * @return string
62
     */
63
    public function getFullTypeName()
64
    {
65
        return 'System.NULL';
66
    }
67
68
    /**
69
     * Converts the given string value to null type.
70
     * 
71
     * @param string $stringValue value to convert
72
     * 
73
     * @return string
74
     */
75
    public function convert($stringValue)
76
    {
77
        if (strcmp($stringValue, 'null') == 0) {
78
            return null;
79
        }
80
81
        return $stringValue;
82
    }
83
84
    /**
85
     * Convert the given value to a form that can be used in OData uri.
86
     * 
87
     * @param mixed $value value to convert
88
     * 
89
     * @return void
90
     * 
91
     * @throws NotImplementedException
92
     */
93
    public function convertToOData($value)
94
    {
95
        throw new NotImplementedException();
96
    }
97
}