Completed
Push — master ( 8d0bd8...93d98b )
by Mike
06:19
created

Classroom::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 1
1
<?php
2
namespace mikemix\Wiziq\Entity;
3
4
class Classroom
5
{
6
    /** @var string */
7
    private $title;
8
9
    /** @var \DateTime */
10
    private $startTime;
11
12
    /** @var string */
13
    private $presenterEmail;
14
15
16 4
    public function __construct($title, \DateTime $startTime, $presenterEmail)
17
    {
18 4
        $this->title          = (string)$title;
19 4
        $this->startTime      = $startTime->format('d/m/Y H:i:s');
0 ignored issues
show
Documentation Bug introduced by
It seems like $startTime->format('d/m/Y H:i:s') of type string is incompatible with the declared type object<DateTime> of property $startTime.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
20 4
        $this->presenterEmail = (string)$presenterEmail;
21 4
    }
22
23
    /**
24
     * @param string     $title
25
     * @param \DateTime  $startTime
26
     * @param string     $presenterEmail
27
     * @return self
28
     */
29 4
    public static function build($title, \DateTime $startTime, $presenterEmail)
30
    {
31 4
        return new self($title, $startTime, $presenterEmail);
32
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function __toString()
38
    {
39
        return $this->title;
40
    }
41
42
    /**
43
     * @return array
44
     */
45 2
    public function toArray()
46
    {
47
        return [
48 2
            'title'               => $this->title,
49 2
            'start_time'              => $this->startTime,
50 2
            'presenter_email'           => $this->presenterEmail,
51 2
        ];
52
    }
53
}
54