Skip to content

Commit 2fe13b8

Browse files
committed
Add VbcConfig to Application
1 parent 7635db3 commit 2fe13b8

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

src/Application/Application.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Application implements EntityInterface, \JsonSerializable, JsonUnserializa
2424
protected $voiceConfig;
2525
protected $messagesConfig;
2626
protected $rtcConfig;
27-
protected $usesVbc = false; // This will become a config if we ever have parameters
27+
protected $vbcConfig;
2828

2929
protected $name;
3030

@@ -42,18 +42,6 @@ public function getId()
4242
return $this->id;
4343
}
4444

45-
public function enableVbc() {
46-
$this->usesVbc = true;
47-
}
48-
49-
public function disableVbc() {
50-
$this->usesVbc = false;
51-
}
52-
53-
public function isVbcEnabled() {
54-
return $this->usesVbc;
55-
}
56-
5745
public function setVoiceConfig(VoiceConfig $config)
5846
{
5947
$this->voiceConfig = $config;
@@ -72,6 +60,12 @@ public function setRtcConfig(RtcConfig $config)
7260
return $this;
7361
}
7462

63+
public function setVbcConfig(VbcConfig $config)
64+
{
65+
$this->vbcConfig = $config;
66+
return $this;
67+
}
68+
7569
/**
7670
* @return VoiceConfig
7771
*/
@@ -126,6 +120,18 @@ public function getRtcConfig()
126120
return $this->rtcConfig;
127121
}
128122

123+
/**
124+
* @return RtcConfig
125+
*/
126+
public function getVbcConfig()
127+
{
128+
if(!isset($this->vbcConfig)){
129+
$this->setVbcConfig(new VbcConfig());
130+
}
131+
132+
return $this->vbcConfig;
133+
}
134+
129135
public function setPublicKey($key)
130136
{
131137
$this->keys['public_key'] = $key;
@@ -191,7 +197,7 @@ public function jsonUnserialize(array $json)
191197
}
192198

193199
if (isset($capabilities['vbc'])) {
194-
$this->enableVbc();
200+
$this->getVbcConfig()->enable();
195201
}
196202
}
197203
}
@@ -224,7 +230,7 @@ public function jsonSerialize()
224230
}
225231

226232
// Handle VBC specifically
227-
if ($this->usesVbc) {
233+
if ($this->vbcConfig->isEnabled()) {
228234
$capabilities['vbc'] = new \StdClass;
229235
}
230236

src/Application/VbcConfig.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Nexmo Client Library for PHP
4+
*
5+
* @copyright Copyright (c) 2019 Nexmo, Inc. (http://nexmo.com)
6+
* @license https://github.com/Nexmo/nexmo-php/blob/master/LICENSE.txt MIT License
7+
*/
8+
9+
namespace Nexmo\Application;
10+
11+
class VbcConfig
12+
{
13+
protected $enabled = false;
14+
15+
public function enable() {
16+
$this->enabled = true;
17+
}
18+
19+
public function disable() {
20+
$this->enabled = false;
21+
}
22+
23+
public function isEnabled() {
24+
return $this->enabled;
25+
}
26+
}

0 commit comments

Comments
 (0)