Classroom::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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 \DateTime $startTime
25
     */
26 13
    private function __construct($title, \DateTime $startTime)
27
    {
28 13
        $this->title     = (string)$title;
29 13
        $this->startTime = $startTime->format('m/d/Y H:i:s');
30 13
    }
31
32
    /**
33
     * @param string    $title
34
     * @param \DateTime $startTime
35
     * @return self
36
     */
37 13
    public static function build($title, \DateTime $startTime)
38
    {
39 13
        return new self($title, $startTime);
40
    }
41
42
    /**
43
     * @param int $value
44
     * @return self
45
     */
46 1
    public function withDuration($value)
47
    {
48 1
        $self = clone $this;
49 1
        $self->duration = (int)$value;
50
51 1
        return $self;
52
    }
53
54
    /**
55
     * @param int $value
56
     * @return self
57
     */
58 1
    public function withExtendDuration($value)
59
    {
60 1
        $self = clone $this;
61 1
        $self->extendDuration = (int)$value;
62
63 1
        return $self;
64
    }
65
66
    /**
67
     * @param string $value
68
     * @return self
69
     */
70 1
    public function withTimeZone($value)
71
    {
72 1
        $self = clone $this;
73 1
        $self->timeZone = (string)$value;
74
75 1
        return $self;
76
    }
77
78
    /**
79
     * @return array
80
     */
81 12
    public function toArray()
82
    {
83
        $params = [
84 12
            'title'                      => $this->title,
85 12
            'start_time'                 => $this->startTime,
86 12
            'language_culture_name'      => $this->languageCultureName,
87 12
            'duration'                   => $this->duration,
88 12
            'time_zone'                  => $this->timeZone,
89 12
            'attendee_limit'             => $this->attendeeLimit,
90 12
            'presenter_default_controls' => $this->presenterDefaultControls,
91 12
            'attendee_default_controls'  => $this->attendeeDefaultControls,
92 12
            'create_recording'           => $this->createRecording,
93 12
            'return_url'                 => $this->returnUrl,
94 12
            'status_ping_url'            => $this->statusPingUrl,
95 12
        ];
96 12
97
        if($this->extendDuration) {
98 12
            $params['extend_duration'] = $this->extendDuration;
99 1
100 1
        }
101 11
102 11 View Code Duplication
        if ($this->presenterEmail) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
103
            $params['presenter_email'] = $this->presenterEmail;
104
        } else {
105 12
            $params['presenter_id']   = $this->presenterId;
106
            $params['presenter_name'] = $this->presenterName;
107
        }
108
109
        return $params;
110
    }
111
}
112