Audience::setTotal()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace Audiens\AdForm\Entity;
4
5
use DateTime;
6
use JsonSerializable;
7
use stdClass;
8
9
/**
10
 * Class Audience
11
 */
12
class Audience implements JsonSerializable
13
{
14
    /** @var string|null */
15
    protected $segmentId;
16
17
    /** @var DateTime|null */
18
    protected $date;
19
20
    /** @var int|null */
21
    protected $total;
22
23
    public function getSegmentId(): ?string
24
    {
25
        return $this->segmentId;
26
    }
27
28
    public function setSegmentId(string $segmentId): void
29
    {
30
        $this->segmentId = $segmentId;
31
    }
32
33
    public function getDate(): ?DateTime
34
    {
35
        return $this->date;
36
    }
37
38
    public function setDate(DateTime $date): void
39
    {
40
        $this->date = $date;
41
    }
42
43
    public function getTotal(): ?int
44
    {
45
        return $this->total;
46
    }
47
48
    public function setTotal(int $total): void
49
    {
50
        $this->total = $total;
51
    }
52
53
    public function jsonSerialize()
54
    {
55
        $obj = new stdClass();
56
57
        $obj->segmentId = $this->segmentId;
58
        $obj->date = $this->date ? $this->date->format('c'): null;
59
        $obj->total = $this->total;
60
61
        return $obj;
62
    }
63
}
64