BeesWaxSegment::setCpmCost()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Audiens\BeesWax\Segment;
4
5
class BeesWaxSegment
6
{
7
    public const SEGMENT_KEY_TYPE_DEFAULT = 'DEFAULT';
8
    public const SEGMENT_KEY_TYPE_ALTERNATIVE = 'ALTERNATIVE';
9
10
    /** @var string|null */
11
    protected $id;
12
13
    /** @var string|null */
14
    protected $alternativeId;
15
16
    /** @var int|null */
17
    protected $advertiserId;
18
19
    /**
20
     * Max 191 characters
21
     * @var string
22
     */
23
    protected $name;
24
25
    /** @var string|null */
26
    protected $description;
27
28
    /** @var float */
29
    protected $cpmCost;
30
31
    /**
32
     * Max 90
33
     * @var int
34
     */
35
    protected $ttlDays;
36
37
    /**
38
     * Should reporting include this segment when it is used as a negative target ("NOT")
39
     * @var bool
40
     */
41
    protected $aggregateExcludes;
42
43
    /**
44
     * BeesWaxSegment constructor.
45
     *
46
     * @param string   $name
47
     * @param string   $description
48
     * @param string   $alternativeId
49
     * @param int|null $advertiserId
50
     * @param float    $cpmCost
51
     * @param int      $ttlDays
52
     * @param bool     $aggregateExcludes
53
     */
54
    public function __construct(
55
        string $name,
56
        ?string $description = null,
57
        ?string $alternativeId = null,
58
        ?int $advertiserId = null,
59
        float $cpmCost = 0,
60
        int $ttlDays = 30,
61
        bool $aggregateExcludes = false
62
    ) {
63
        $this->alternativeId = $alternativeId;
64
        $this->advertiserId = $advertiserId;
65
        $this->name = $name;
66
        $this->description = $description;
67
        $this->cpmCost = $cpmCost;
68
        $this->ttlDays = $ttlDays;
69
        $this->aggregateExcludes = $aggregateExcludes;
70
    }
71
72
    public function setId(string $id): BeesWaxSegment
73
    {
74
        $this->id = $id;
75
76
        return $this;
77
    }
78
79
    public function getId(): ?string
80
    {
81
        return $this->id;
82
    }
83
84
    public function getAlternativeId(): ?string
85
    {
86
        return $this->alternativeId;
87
    }
88
89
    public function getAdvertiserId(): ?int
90
    {
91
        return $this->advertiserId;
92
    }
93
94
    public function getName(): string
95
    {
96
        return $this->name;
97
    }
98
99
    public function getDescription(): ?string
100
    {
101
        return $this->description;
102
    }
103
104
    public function getCpmCost(): float
105
    {
106
        return $this->cpmCost;
107
    }
108
109
    public function getTtlDays(): int
110
    {
111
        return $this->ttlDays;
112
    }
113
114
    public function isAggregateExcludes(): bool
115
    {
116
        return $this->aggregateExcludes;
117
    }
118
119
    public function setAlternativeId(?string $alternativeId): void
120
    {
121
        $this->alternativeId = $alternativeId;
122
    }
123
124
    public function setAdvertiserId(?int $advertiserId): void
125
    {
126
        $this->advertiserId = $advertiserId;
127
    }
128
129
    public function setName(string $name): void
130
    {
131
        $this->name = $name;
132
    }
133
134
    public function setDescription(?string $description): void
135
    {
136
        $this->description = $description;
137
    }
138
139
    public function setCpmCost(float $cpmCost): void
140
    {
141
        $this->cpmCost = $cpmCost;
142
    }
143
144
    public function setAggregateExcludes(bool $aggregateExcludes): void
145
    {
146
        $this->aggregateExcludes = $aggregateExcludes;
147
    }
148
149
    public function equals(BeesWaxSegment $segment): bool
150
    {
151
        foreach (get_object_vars($this) as $key => $value) {
152
            if ($segment->$key !== $this->$key) {
153
                return false;
154
            }
155
        }
156
157
        return true;
158
    }
159
}
160