Passed
Push — master ( 188fde...56d8c7 )
by Christopher
10:58 queued 06:48
created

TTypeRefType::setType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\Groups\GEmptyElementExtensibilityTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\Groups\TFacetAttributesTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TUnwrappedFunctionTypeTrait;
9
10
/**
11
 * Class representing TTypeRefType
12
 *
13
 * XSD Type: TTypeRef
14
 */
15
class TTypeRefType extends IsOK
16
{
17
    use GEmptyElementExtensibilityTrait, TFacetAttributesTrait, TUnwrappedFunctionTypeTrait {
18
        TFacetAttributesTrait::isStringNotNullOrEmpty insteadof GEmptyElementExtensibilityTrait;
19
        TFacetAttributesTrait::isStringNotNull insteadof GEmptyElementExtensibilityTrait;
20
        TFacetAttributesTrait::isNotNullInstanceOf insteadof GEmptyElementExtensibilityTrait;
21
        TFacetAttributesTrait::isNullInstanceOf insteadof GEmptyElementExtensibilityTrait;
22
        TFacetAttributesTrait::isURLValid insteadof GEmptyElementExtensibilityTrait;
23
        TFacetAttributesTrait::isObjectNullOrOK insteadof GEmptyElementExtensibilityTrait;
24
        TFacetAttributesTrait::isObjectNullOrType insteadof GEmptyElementExtensibilityTrait;
25
        TFacetAttributesTrait::isValidArrayOK insteadof GEmptyElementExtensibilityTrait;
26
        TFacetAttributesTrait::isValidArray insteadof GEmptyElementExtensibilityTrait;
27
        TFacetAttributesTrait::isChildArrayOK insteadof GEmptyElementExtensibilityTrait;
28
    }
29
    
30
    /**
31
     * @property string $type
32
     */
33
    private $type = null;
34
35
     /**
36
      * Gets as type
37
      *
38
      * @return string
39
      */
40
    public function getType()
41
    {
42
        return $this->type;
43
    }
44
45
    /**
46
     * Sets a new type
47
     *
48
     * @param  string $type
49
     * @return self
50
     */
51
    public function setType($type)
52
    {
53
        if (!$this->isTUnwrappedFunctionTypeValid($type)) {
54
            $msg = "Type must be a valid TUnwrappedFunctionType";
55
            throw new \InvalidArgumentException($msg);
56
        }
57
        $this->type = $type;
58
        return $this;
59
    }
60
61
    public function isOK(&$msg = null)
62
    {
63
        if (!$this->isTUnwrappedFunctionTypeValid($this->type)) {
64
            $msg = "Type must be a valid TUnwrappedFunctionType";
65
            return false;
66
        }
67
        if (!$this->isExtensibilityElementOK($msg)) {
68
            return false;
69
        }
70
        if (!$this->isTFacetAttributesTraitValid($msg)) {
71
            return false;
72
        }
73
        return true;
74
    }
75
}
76