Completed
Pull Request — master (#98)
by Christopher
05:13
created

AppServiceType::isOK()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\App;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait;
7
8
/**
9
 * Class representing AppServiceType
10
 *
11
 *
12
 * XSD Type: appServiceType
13
 */
14 View Code Duplication
class AppServiceType extends IsOK
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
    use IsOKToolboxTrait;
17
18
    /**
19
     * @property \AlgoWeb\ODataMetadata\Atom\Author $author
20
     */
21
    private $author = null;
22
23
    /**
24
     * @property \AlgoWeb\ODataMetadata\App\Workspace[] $workspace
25
     */
26
    private $workspace = array();
27
28
    /**
29
     * Gets as author
30
     *
31
     * @return \AlgoWeb\ODataMetadata\Atom\Author
32
     */
33
    public function getAuthor()
34
    {
35
        return $this->author;
36
    }
37
38
    /**
39
     * Sets a new author
40
     *
41
     * @param \AlgoWeb\ODataMetadata\Atom\Author $author
42
     * @return self
43
     */
44
    public function setAuthor(\AlgoWeb\ODataMetadata\Atom\Author $author)
45
    {
46
        $this->author = $author;
47
        return $this;
48
    }
49
50
    /**
51
     * Adds as workspace
52
     *
53
     * @return self
54
     * @param \AlgoWeb\ODataMetadata\App\Workspace $workspace
55
     */
56
    public function addToWorkspace(\AlgoWeb\ODataMetadata\App\Workspace $workspace)
57
    {
58
        $this->workspace[] = $workspace;
59
        return $this;
60
    }
61
62
    /**
63
     * isset workspace
64
     *
65
     * @param scalar $index
66
     * @return boolean
67
     */
68
    public function issetWorkspace($index)
69
    {
70
        return isset($this->workspace[$index]);
71
    }
72
73
    /**
74
     * unset workspace
75
     *
76
     * @param scalar $index
77
     * @return void
78
     */
79
    public function unsetWorkspace($index)
80
    {
81
        unset($this->workspace[$index]);
82
    }
83
84
    /**
85
     * Gets as workspace
86
     *
87
     * @return \AlgoWeb\ODataMetadata\App\Workspace[]
88
     */
89
    public function getWorkspace()
90
    {
91
        return $this->workspace;
92
    }
93
94
    /**
95
     * Sets a new workspace
96
     *
97
     * @param \AlgoWeb\ODataMetadata\App\Workspace[] $workspace
98
     * @return self
99
     */
100
    public function setWorkspace(array $workspace)
101
    {
102
        $this->workspace = $workspace;
103
        return $this;
104
    }
105
106
    public function isOK(&$msg = null)
107
    {
108
        if (!$this->isObjectNullOrType('\AlgoWeb\ODataMetadata\Atom\Author', $this->author, $msg)) {
0 ignored issues
show
Documentation introduced by
$this->author is of type object<AlgoWeb\ODataMetadata\Atom\Author>, but the function expects a null|object<AlgoWeb\ODataMetadata\IsOK>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
109
            return false;
110
        }
111
        if ($this->isObjectNullOrOK($this->author, $msg)) {
0 ignored issues
show
Documentation introduced by
$this->author is of type object<AlgoWeb\ODataMetadata\Atom\Author>, but the function expects a null|object<AlgoWeb\ODataMetadata\IsOK>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
112
            return false;
113
        }
114
        if ($this->isValidArrayOK($this->workspace, '\AlgoWeb\ODataMetadata\App\Workspace', $msg, 1)) {
115
            return false;
116
        }
117
        return true;
118
    }
119
}
120