Completed
Push — master ( 088987...65ed73 )
by Brian
03:46
created

Dial::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 2
crap 2
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 phparia\Client\AriClient;
22
use phparia\Resources\Channel;
23
24
/**
25
 * Dialing state has changed.
26
 *
27
 * @author Brian Smith <[email protected]>
28
 */
29
class Dial extends Event
30
{
31
    /**
32
     * Valid dialstatus values
33
     */
34
    const DIALSTATUS_ANSWER = 'answer';
35
    const DIALSTATUS_BUSY = 'busy';
36
    const DIALSTATUS_NOANSWER = 'noanswer';
37
    const DIALSTATUS_CANCEL = 'cancel';
38
    const DIALSTATUS_CONGESTION = 'congestion';
39
    const DIALSTATUS_CHANUNAVAIL = 'chanunavail';
40
    const DIALSTATUS_DONTCALL = 'dontcall';
41
    const DIALSTATUS_TORTURE = 'torture';
42
    const DIALSTATUS_INVALIDARGS = 'invalidargs';
43
44
    /**
45
     * @var Channel (optional) - The channel on which the variable was set. If missing, the variable is a global variable.
46
     */
47
    private $caller;
48
49
    /**
50
     * @var string Current status of the dialing attempt to the peer.
51
     */
52
    private $dialstatus;
53
54
    /**
55
     * @var string (optional) - The dial string for calling the peer channel.
56
     */
57
    private $dialstring;
58
59
    /**
60
     * @var string (optional) - Forwarding target requested by the original dialed channel.
61
     */
62
    private $forward;
63
64
    /**
65
     * @var Channel (optional) - Channel that the caller has been forwarded to.
66
     */
67
    private $forwarded;
68
69
    /**
70
     * @var Channel The dialed channel.
71
     */
72
    private $peer;
73
74
    /**
75
     * @return Channel (optional) - The calling channel.
76
     */
77
    public function getCaller()
78
    {
79
        return $this->caller;
80
    }
81
82
    /**
83
     * @return string - Current status of the dialing attempt to the peer.
84
     */
85
    public function getDialstatus()
86
    {
87
        return $this->dialstatus;
88
    }
89
90
    /**
91
     * @return string (optional) - The dial string for calling the peer channel.
92
     */
93
    public function getDialstring()
94
    {
95
        return $this->dialstring;
96
    }
97
98
    /**
99
     * @return string (optional) - Forwarding target requested by the original dialed channel.
100
     */
101
    public function getForward()
102
    {
103
        return $this->forward;
104
    }
105
106
    /**
107
     * @return Channel (optional) - Forwarding target requested by the original dialed channel.
108
     */
109
    public function getForwarded()
110
    {
111
        return $this->forwarded;
112
    }
113
114
    /**
115
     * @return Channel The dialed channel.
116
     */
117
    public function getPeer()
118
    {
119
        return $this->peer;
120
    }
121
122
    /**
123
     * @param AriClient $client
124
     * @param string $response
125
     */
126
    public function __construct(AriClient $client, $response)
127
    {
128
        parent::__construct($client, $response);
129
130
        $this->caller = $this->getResponseValue('channel', '\phparia\Resources\Channel', $client);
131
        $this->dialstatus = $this->getResponseValue('dialstatus');
132
        $this->dialstring = $this->getResponseValue('dialstring');
133
        $this->forward = $this->getResponseValue('forward');
134
        $this->forwarded = $this->getResponseValue('forwarded', '\phparia\Resources\Channel', $client);
135
        $this->peer = $this->getResponseValue('peer');
136
    }
137
}
138