FlashMessage::getTypes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php namespace JobApis\JobsToMail\Http\Messages;
2
3
class FlashMessage
4
{
5
    /**
6
     * The message text
7
     *
8
     * @var string
9
     */
10
    public $message;
11
12
    /**
13
     * Type of message being created
14
     *
15
     * @var string
16
     */
17
    public $type;
18
19
    /**
20
     * FlashMessage constructor.
21
     *
22
     * @param null $type
23
     * @param null $message
24
     *
25
     * @throws \OutOfBoundsException
26
     */
27 14
    public function __construct($type = null, $message = null)
28
    {
29 14
        if ($type && in_array($type, $this->getTypes())) {
30 13
            $this->type = $type;
31 13
            $this->message = $message;
32
        } else {
33 1
            throw new \OutOfBoundsException("Invalid type {$type} specified.");
34
        }
35 13
    }
36
37
    /**
38
     * Valid types
39
     *
40
     * @return array
41
     */
42 14
    protected function getTypes()
43
    {
44
        return [
45 14
            'alert-danger',
46
            'alert-success',
47
        ];
48
    }
49
}
50