Passed
Push — master ( 26efa5...f69765 )
by Alex
03:20
created

TIncludeType::isOK()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 24
Code Lines 15

Duplication

Lines 10
Ratio 41.67 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 24
rs 8.5125
cc 6
eloc 15
nc 6
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV4\edmx;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
7
/**
8
 * Class representing TIncludeType
9
 *
10
 *
11
 * XSD Type: TInclude
12
 */
13
class TIncludeType extends IsOK
14
{
15
16
    /**
17
     * @property string $namespace
18
     */
19
    private $namespace = null;
20
21
    /**
22
     * @property string $alias
23
     */
24
    private $alias = null;
25
26
    /**
27
     * Gets as namespace
28
     *
29
     * @return string
30
     */
31
    public function getNamespace()
32
    {
33
        return $this->namespace;
34
    }
35
36
    /**
37
     * Sets a new namespace
38
     *
39
     * @param string $namespace
40
     * @return self
41
     */
42
    public function setNamespace($namespace)
43
    {
44
        $this->namespace = $namespace;
45
        return $this;
46
    }
47
48
    /**
49
     * Gets as alias
50
     *
51
     * @return string
52
     */
53
    public function getAlias()
54
    {
55
        return $this->alias;
56
    }
57
58
    /**
59
     * Sets a new alias
60
     *
61
     * @param string $alias
62
     * @return self
63
     */
64
    public function setAlias($alias)
65
    {
66
        $this->alias = $alias;
67
        return $this;
68
    }
69
70
    protected function isOK(&$msg = null)
71
    {
72
        if (!$this->isStringNotNullOrEmpty($this->namespace)) {
73
            $msg = "Namespace Must be defined";
74
            return false;
75
        }
76
        if (!$this->isTNamespaceNameValid($this->namespace)) {
0 ignored issues
show
Bug introduced by
The method isTNamespaceNameValid() does not seem to exist on object<AlgoWeb\ODataMeta...taV4\edmx\TIncludeType>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
            $msg = "Namespace Must be a valid NameSpace";
78
            return false;
79
        }
80
81
82 View Code Duplication
        if (null != $this->alias) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
83
            if (!is_string($this->alias)) {
84
                $msg = "Alias must be either a string or null";
85
                return false;
86
            }
87
            if (!$this->isTSimpleIdentifierValid($this->alias)) {
0 ignored issues
show
Bug introduced by
The method isTSimpleIdentifierValid() does not seem to exist on object<AlgoWeb\ODataMeta...taV4\edmx\TIncludeType>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
                $msg = "Alias must be a valid TSimpleIdentifier";
89
                return false;
90
            }
91
        }
92
        return true;
93
    }
94
}
95