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\Resources; |
20
|
|
|
|
21
|
|
|
use phparia\Client\AriClient; |
22
|
|
|
use phparia\Events\Event; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* An external device that may offer/accept calls to/from Asterisk. |
26
|
|
|
* |
27
|
|
|
* @author Brian Smith <[email protected]> |
28
|
|
|
*/ |
29
|
|
|
class Endpoint extends Resource |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var array Id's of channels associated with this endpoint |
33
|
|
|
*/ |
34
|
|
|
private $channelIds; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string Identifier of the endpoint, specific to the given technology. |
38
|
|
|
*/ |
39
|
|
|
private $resource; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string (optional) - Endpoint's state |
43
|
|
|
*/ |
44
|
|
|
private $state; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string Technology of the endpoint |
48
|
|
|
*/ |
49
|
|
|
private $technology; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return array Id's of channels associated with this endpoint |
53
|
|
|
*/ |
54
|
|
|
public function getChannelIds() |
55
|
|
|
{ |
56
|
|
|
return $this->channelIds; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string Identifier of the endpoint, specific to the given technology. |
61
|
|
|
*/ |
62
|
|
|
public function getResource() |
63
|
|
|
{ |
64
|
|
|
return $this->resource; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string (optional) - Endpoint's state |
69
|
|
|
*/ |
70
|
|
|
public function getState() |
71
|
|
|
{ |
72
|
|
|
return $this->state; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return string Technology of the endpoint |
77
|
|
|
*/ |
78
|
|
|
public function getTechnology() |
79
|
|
|
{ |
80
|
|
|
return $this->technology; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param callable $callback |
85
|
|
|
*/ |
86
|
|
|
public function onEndpointStateChange(callable $callback) |
87
|
|
|
{ |
88
|
|
|
$this->on(Event::ENDPOINT_STATE_CHANGE.'_'.$this->getResource(), $callback); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param callable $callback |
93
|
|
|
*/ |
94
|
|
|
public function onceEndpointStateChange(callable $callback) |
95
|
|
|
{ |
96
|
|
|
$this->once(Event::ENDPOINT_STATE_CHANGE.'_'.$this->getResource(), $callback); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param AriClient $client |
101
|
|
|
* @param string $response |
102
|
|
|
*/ |
103
|
|
|
public function __construct(AriClient $client, $response) |
104
|
|
|
{ |
105
|
|
|
parent::__construct($client, $response); |
106
|
|
|
|
107
|
|
|
$this->channelIds = $this->getResponseValue('channel_ids'); |
|
|
|
|
108
|
|
|
$this->resource = $this->getResponseValue('resource'); |
109
|
|
|
$this->state = $this->getResponseValue('state'); |
110
|
|
|
$this->technology = $this->getResponseValue('technology'); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
} |
114
|
|
|
|
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..