Completed
Push — master ( fbdd5a...4063fa )
by Mike
04:02
created

Classroom::withExtendDuration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
namespace mikemix\Wiziq\Entity;
3
4
use mikemix\Wiziq\Entity\Traits\ClassroomTrait;
5
6
class Classroom
7
{
8
    use ClassroomTrait;
9
    
10
    /** @var string */
11
    private $startTime;
12
13
    /** @var int */
14
    private $duration;
15
16
    /** @var int */
17
    private $extendDuration;
18
19
    /** @var string */
20
    private $timeZone;
21
22
    /**
23
     * @param string    $title
24
     * @param string    $presenterEmail
25
     * @param \DateTime $startTime
26
     */
27 12
    private function __construct($title, $presenterEmail, \DateTime $startTime)
28
    {
29 12
        $this->title          = (string)$title;
30 12
        $this->presenterEmail = (string)$presenterEmail;
31 12
        $this->startTime      = $startTime->format('d/m/Y H:i:s');
32 12
    }
33
34
    /**
35
     * @param string    $title
36
     * @param string    $presenterEmail
37
     * @param \DateTime $startTime
38
     * @return self
39
     */
40 12
    public static function build($title, $presenterEmail, \DateTime $startTime)
41
    {
42 12
        return new self($title, $presenterEmail, $startTime);
43
    }
44
45
    /**
46
     * @param int $value
47
     * @return self
48
     */
49 1
    public function withDuration($value)
50
    {
51 1
        $self = clone $this;
52 1
        $self->duration = (int)$value;
53
54 1
        return $self;
55
    }
56
57
    /**
58
     * @param int $value
59
     * @return self
60
     */
61 1
    public function withExtendDuration($value)
62
    {
63 1
        $self = clone $this;
64 1
        $self->extendDuration = (int)$value;
65
66 1
        return $self;
67
    }
68
69
    /**
70
     * @param string $value
71
     * @return self
72
     */
73 1
    public function withTimeZone($value)
74
    {
75 1
        $self = clone $this;
76 1
        $self->timeZone = (string)$value;
77
78 1
        return $self;
79
    }
80
81
    /**
82
     * @return array
83
     */
84 11
    public function toArray()
85
    {
86
        return [
87 11
            'title'                      => $this->title,
88 11
            'start_time'                 => $this->startTime,
89 11
            'presenter_email'            => $this->presenterEmail,
90 11
            'language_culture_name'      => $this->languageCultureName,
91 11
            'extend_duration'            => $this->extendDuration,
92 11
            'duration'                   => $this->duration,
93 11
            'time_zone'                  => $this->timeZone,
94 11
            'attendee_limit'             => $this->attendeeLimit,
95 11
            'presenter_default_controls' => $this->presenterDefaultControls,
96 11
            'attendee_default_controls'  => $this->attendeeDefaultControls,
97 11
            'create_recording'           => $this->createRecording,
98 11
            'return_url'                 => $this->returnUrl,
99 11
            'status_ping_url'            => $this->statusPingUrl,
100 11
        ];
101
    }
102
}
103