Completed
Push — master ( ef8259...e600b3 )
by Giacomo "Mr. Wolf"
02:28
created

BeesWaxSegment::equals()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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