NotificationEvent::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4222
c 0
b 0
f 0
cc 5
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the XabbuhPandaClient package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\PandaClient\Model;
13
14
/**
15
 * Representation of notification events consisting of an event name and its
16
 * activation state.
17
 *
18
 * @author Christian Flothmann <[email protected]>
19
 */
20
class NotificationEvent
21
{
22
    private $event;
23
24
    private $active;
25
26
    public function __construct($event, $active)
27
    {
28
        // normalise event names
29
        $event = strtr($event, '_', '-');
30
31
        // check for valid event names
32
        if (
33
            $event != 'video-created' && $event != 'video-encoded' &&
34
            $event != 'encoding-progress' && $event != 'encoding-completed'
35
        ) {
36
            throw new \InvalidArgumentException('Unknown notification event $event');
37
        }
38
39
        $this->event = $event;
40
        $this->active = $active;
41
    }
42
43
    public function getEvent()
44
    {
45
        return $this->event;
46
    }
47
48
    public function isActive()
49
    {
50
        return $this->active;
51
    }
52
}
53