Event   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 86
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getApplication() 0 4 1
A getTimestamp() 0 4 1
A __construct() 0 9 1
1
<?php
2
3
/*
4
 * Copyright 2014 Brian Smith <[email protected]>.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *      http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace phparia\Events;
20
21
use DateTime;
22
use phparia\Client\AriClient;
23
24
/**
25
 * Base type for asynchronous events from Asterisk.
26
 *
27
 * @author Brian Smith <[email protected]>
28
 */
29
class Event extends Message implements EventInterface
30
{
31
    // ARI events
32
    const APPLICATION_REPLACED = 'ApplicationReplaced';
33
    const BRIDGE_ATTENDED_TRANSFER = 'BridgeAttendedTransfer';
34
    const BRIDGE_BLIND_TRANSFER = 'BridgeBlindTransfer';
35
    const BRIDGE_CREATED = 'BridgeCreated';
36
    const BRIDGE_DESTROYED = 'BridgeDestroyed';
37
    const BRIDGE_MERGED = 'BridgeMerged';
38
    const BRIDGE_VIDEO_SOURCE_CHANGED = 'BridgeVideoSourceChanged';
39
    const CHANNEL_CALLER_ID = 'ChannelCallerId';
40
    const CHANNEL_CREATED = 'ChannelCreated';
41
    const CHANNEL_CONNECTED_LINE = 'ChannelConnectedLine';
42
    const CHANNEL_DESTROYED = 'ChannelDestroyed';
43
    const CHANNEL_DIALPLAN = 'ChannelDialplan';
44
    const CHANNEL_DTMF_RECEIVED = 'ChannelDtmfReceived';
45
    const CHANNEL_ENTERED_BRIDGE = 'ChannelEnteredBridge';
46
    const CHANNEL_HANGUP_REQUEST = 'ChannelHangupRequest';
47
    const CHANNEL_LEFT_BRIDGE = 'ChannelLeftBridge';
48
    const CHANNEL_STATE_CHANGE = 'ChannelStateChange';
49
    const CHANNEL_HOLD = 'ChannelHold';
50
    const CHANNEL_UNHOLD = 'ChannelUnhold';
51
    const CHANNEL_TALKING_FINISHED = 'ChannelTalkingFinished';
52
    const CHANNEL_TALKING_STARTED = 'ChannelTalkingStarted';
53
    const CHANNEL_USEREVENT = 'ChannelUserevent';
54
    const CHANNEL_VARSET = 'ChannelVarset';
55
    const DEVICE_STATE_CHANGED = 'DeviceStateChanged';
56
    const DIAL = 'Dial';
57
    const DIALED = 'Dialed';
58
    const ENDPOINT_STATE_CHANGE = 'EndpointStateChange';
59
    const PEER_STATUS_CHANGE = 'PeerStatusChange';
60
    const PLAYBACK_CONTINUING = 'PlaybackContinuing';
61
    const PLAYBACK_FINISHED = 'PlaybackFinished';
62
    const PLAYBACK_STARTED = 'PlaybackStarted';
63
    const RECORDING_FAILED = 'RecordingFailed';
64
    const RECORDING_FINISHED = 'RecordingFinished';
65
    const RECORDING_STARTED = 'RecordingStarted';
66
    const STASIS_END = 'StasisEnd';
67
    const STASIS_START = 'StasisStart';
68
    const TEXT_MESSAGE_RECEIVED = 'TextMessageReceived';
69
70
    /**
71
     * @var AriClient
72
     */
73
    protected $client;
74
75
    /**
76
     * @var string Name of the application receiving the event.
77
     */
78
    private $application;
79
80
    /**
81
     * @var DateTime (optional) - Time at which this event was created.
82
     */
83
    private $timestamp;
84
85
    /**
86
     * @return string Name of the application receiving the event.
87
     */
88
    public function getApplication()
89
    {
90
        return $this->application;
91
    }
92
93
    /**
94
     * @return \DateTime (optional) - Time at which this event was created.
95
     */
96
    public function getTimestamp()
97
    {
98
        return $this->timestamp;
99
    }
100
101
    /**
102
     * @param AriClient $client
103
     * @param string $response
104
     */
105
    public function __construct(AriClient $client, $response)
106
    {
107
        $this->client = $client;
108
109
        parent::__construct($response);
110
111
        $this->application = $this->getResponseValue('application');
112
        $this->timestamp = $this->getResponseValue('timestamp', '\DateTime');
113
    }
114
}
115