GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Audience   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 153
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 18
lcom 1
cbo 2
dl 0
loc 153
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A setId() 0 4 1
A getName() 0 4 1
A setName() 0 4 1
A getDescription() 0 4 1
A setDescription() 0 4 1
A getModifiedAt() 0 4 1
A setModifiedAt() 0 4 1
A getTargetRuleLogicalCondition() 0 4 1
A setTargetRuleLogicalCondition() 0 4 1
A getTargetRuleConditions() 0 4 1
A setTargetRuleConditions() 0 4 1
A toArray() 0 13 2
A fromArray() 0 14 4
1
<?php
2
3
namespace Audiens\AdobeClient\Entity\Target;
4
5
use Audiens\AdobeClient\Entity\HydratableTrait;
6
7
/**
8
 * Class Audience
9
 */
10
class Audience
11
{
12
    const TARGET_RULE_AND = 'AND';
13
    const TARGET_RULE_OR  = 'OR';
14
15
    use HydratableTrait;
16
17
    /** @var  int */
18
    protected $id;
19
20
    /** @var  string */
21
    protected $name;
22
23
    /** @var  string */
24
    protected $description;
25
26
    /** @var \DateTime */
27
    protected $modifiedAt;
28
29
    /** @var string */
30
    protected $targetRuleLogicalCondition;
31
32
    /** @var array */
33
    protected $targetRuleConditions = [];
34
35
    /**
36
     * @return int
37
     */
38
    public function getId()
39
    {
40
        return $this->id;
41
    }
42
43
    /**
44
     * @param int $id
45
     */
46
    public function setId($id)
47
    {
48
        $this->id = $id;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getName()
55
    {
56
        return $this->name;
57
    }
58
59
    /**
60
     * @param string $name
61
     */
62
    public function setName($name)
63
    {
64
        $this->name = $name;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getDescription()
71
    {
72
        return $this->description;
73
    }
74
75
    /**
76
     * @param string $description
77
     */
78
    public function setDescription($description)
79
    {
80
        $this->description = $description;
81
    }
82
83
    /**
84
     * @return \DateTime
85
     */
86
    public function getModifiedAt()
87
    {
88
        return $this->modifiedAt;
89
    }
90
91
    /**
92
     * @param \DateTime $modifiedAt
93
     */
94
    public function setModifiedAt($modifiedAt)
95
    {
96
        $this->modifiedAt = $modifiedAt;
97
    }
98
99
    /**
100
     * @return string
101
     */
102
    public function getTargetRuleLogicalCondition()
103
    {
104
        return $this->targetRuleLogicalCondition;
105
    }
106
107
    /**
108
     * @param string $targetRuleLogicalCondition
109
     */
110
    public function setTargetRuleLogicalCondition($targetRuleLogicalCondition)
111
    {
112
        $this->targetRuleLogicalCondition = $targetRuleLogicalCondition;
113
    }
114
115
    /**
116
     * @return array
117
     */
118
    public function getTargetRuleConditions()
119
    {
120
        return $this->targetRuleConditions;
121
    }
122
123
    /**
124
     * @param array $targetRuleConditions
125
     */
126
    public function setTargetRuleConditions($targetRuleConditions)
127
    {
128
        $this->targetRuleConditions = $targetRuleConditions;
129
    }
130
131
    public function toArray()
132
    {
133
        $returnArray = [
134
            'name'        => $this->getName(),
135
            'description' => $this->getDescription(),
136
        ];
137
138
        if (!empty($this->targetRuleLogicalCondition)) {
139
            $returnArray['targetRule'] = [$this->targetRuleLogicalCondition => $this->getTargetRuleConditions()];
140
        }
141
142
        return $returnArray;
143
    }
144
145
    /**
146
     * @override
147
     */
148
    public static function fromArray(array $objectArray)
149
    {
150
        $object = new self();
151
        self::getHydrator()->hydrate($objectArray, $object);
152
153
        if (isset($objectArray['targetRule']) && count($objectArray['targetRule']) > 0) {
154
            foreach ($objectArray['targetRule'] as $logical => $rule) {
155
                $object->targetRuleLogicalCondition = $logical;
0 ignored issues
show
Documentation Bug introduced by
It seems like $logical can also be of type integer. However, the property $targetRuleLogicalCondition is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
156
                $object->targetRuleConditions       = $rule;
157
            }
158
        }
159
160
        return $object;
161
    }
162
}
163