From 3d0ae7506eb5a50f6a4289edd5b7dd8c43e9a7b9 Mon Sep 17 00:00:00 2001 From: Thomas Vargiu Date: Fri, 8 Sep 2017 11:39:00 +0200 Subject: [PATCH 1/4] Fixed PHP7 precedence --- src/PAGI/Client/Impl/MockedClientImpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PAGI/Client/Impl/MockedClientImpl.php b/src/PAGI/Client/Impl/MockedClientImpl.php index 3c64ce1..d0a7ece 100644 --- a/src/PAGI/Client/Impl/MockedClientImpl.php +++ b/src/PAGI/Client/Impl/MockedClientImpl.php @@ -124,7 +124,7 @@ private function assertCall($methodName, array $arguments) $count = count($args); for ($i = 0; $i < $count; $i++) { if (!isset($arguments[$i])) { - throw new MockedException("Missing argument number " . $i + 1); + throw new MockedException("Missing argument number " . ($i + 1)); } $arg = $arguments[$i]; if ($arg !== $args[$i]) { From ab0890a068d30f08c2e204b7b86d9bc8acc9587a Mon Sep 17 00:00:00 2001 From: Thomas Vargiu Date: Fri, 8 Sep 2017 11:40:04 +0200 Subject: [PATCH 2/4] Support for agi_network and agi_network_script variables --- .../ChannelVariables/IChannelVariables.php | 14 ++++++++++++++ .../Impl/ChannelVariablesFacade.php | 18 ++++++++++++++++++ test/channelvars/Test_ChannelVariables.php | 2 ++ test/client/Test_Client.php | 2 ++ 4 files changed, 36 insertions(+) diff --git a/src/PAGI/ChannelVariables/IChannelVariables.php b/src/PAGI/ChannelVariables/IChannelVariables.php index e143686..9390d2c 100644 --- a/src/PAGI/ChannelVariables/IChannelVariables.php +++ b/src/PAGI/ChannelVariables/IChannelVariables.php @@ -291,4 +291,18 @@ public function getDirectoryKey(); * @return string */ public function getDirectoryRun(); + + /** + * Returns agi_network_script. + * + * @return string + */ + public function getNetworkScript(); + + /** + * Returns agi_network. + * + * @return string + */ + public function getNetwork(); } diff --git a/src/PAGI/ChannelVariables/Impl/ChannelVariablesFacade.php b/src/PAGI/ChannelVariables/Impl/ChannelVariablesFacade.php index 0984aac..f456790 100644 --- a/src/PAGI/ChannelVariables/Impl/ChannelVariablesFacade.php +++ b/src/PAGI/ChannelVariables/Impl/ChannelVariablesFacade.php @@ -394,4 +394,22 @@ public function __construct(array $variables, array $arguments) $this->variables = $variables; $this->arguments = $arguments; } + + /** + * (non-PHPdoc) + * @see PAGI\ChannelVariables.IChannelVariables::getNetworkScript() + */ + public function getNetworkScript() + { + return $this->getAGIVariable('network_script'); + } + + /** + * (non-PHPdoc) + * @see PAGI\ChannelVariables.IChannelVariables::getNetwork() + */ + public function getNetwork() + { + return $this->getAGIVariable('network'); + } } diff --git a/test/channelvars/Test_ChannelVariables.php b/test/channelvars/Test_ChannelVariables.php index 79ed1f6..e83c769 100644 --- a/test/channelvars/Test_ChannelVariables.php +++ b/test/channelvars/Test_ChannelVariables.php @@ -104,6 +104,8 @@ public function can_get_agi_variables() $vars->getArguments() ); $this->assertFalse($vars->getArgument(4)); + $this->assertEquals($vars->getNetwork(), 'yes'); + $this->assertEquals($vars->getNetworkScript(), 'ScriptName'); $refObject = new \ReflectionObject($vars); $refMethod = $refObject->getMethod('getAGIVariable'); $refMethod->setAccessible(true); diff --git a/test/client/Test_Client.php b/test/client/Test_Client.php index 5bacb1a..ce702ff 100644 --- a/test/client/Test_Client.php +++ b/test/client/Test_Client.php @@ -69,6 +69,8 @@ 'agi_enhanced:0.0', 'agi_accountcode:123', 'agi_threadid:1105672528', + 'agi_network:yes', + 'agi_network_script:ScriptName', '' ); From d9c7ac5f10053bc1b8e09955698635f8edf98bdb Mon Sep 17 00:00:00 2001 From: Thomas Vargiu Date: Fri, 8 Sep 2017 12:02:39 +0200 Subject: [PATCH 3/4] PHPCS --- src/PAGI/Application/PAGILauncher.php | 4 +--- src/PAGI/Client/AbstractClient.php | 5 ++--- src/PAGI/Node/Node.php | 2 -- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/PAGI/Application/PAGILauncher.php b/src/PAGI/Application/PAGILauncher.php index e525e32..74e89f6 100644 --- a/src/PAGI/Application/PAGILauncher.php +++ b/src/PAGI/Application/PAGILauncher.php @@ -31,14 +31,12 @@ * limitations under the License. * */ -use PAGI\Application\Exception\InvalidApplicationException; -use PAGI\Application\PAGIApplication; $appName = getenv('PAGIApplication'); $bootstrap = getenv('PAGIBootstrap'); $myApp = ''; -try { +try { include_once $bootstrap; if (!class_exists($appName, true)) { throw new \Exception($appName . ' is not loaded'); diff --git a/src/PAGI/Client/AbstractClient.php b/src/PAGI/Client/AbstractClient.php index 8092b47..548e803 100644 --- a/src/PAGI/Client/AbstractClient.php +++ b/src/PAGI/Client/AbstractClient.php @@ -66,7 +66,7 @@ abstract class AbstractClient implements IClient { /** * PSR-3 logger. - * @var Logger + * @var LoggerInterface */ protected $logger; @@ -573,7 +573,6 @@ public function log($msg, $priority = 'NOTICE') array($priority, str_replace('"', '\\"', $line)) ); } - } /** @@ -888,7 +887,7 @@ public function createNodeController($name) /** * Sets the logger implementation. * - * @param Psr\Log\LoggerInterface $logger The PSR3-Logger + * @param LoggerInterface $logger The PSR3-Logger * * @return void */ diff --git a/src/PAGI/Node/Node.php b/src/PAGI/Node/Node.php index bfb1e4d..86b1f93 100644 --- a/src/PAGI/Node/Node.php +++ b/src/PAGI/Node/Node.php @@ -1184,7 +1184,6 @@ protected function doInput() */ protected function beforeOnValidInput() { - } /** @@ -1194,7 +1193,6 @@ protected function beforeOnValidInput() */ protected function beforeOnInputFailed() { - } /** From 466cfc90924d5b6cf8c474117a5336df7821d9df Mon Sep 17 00:00:00 2001 From: Thomas Vargiu Date: Fri, 8 Sep 2017 12:03:57 +0200 Subject: [PATCH 4/4] Updated documentation --- doc/PAGI-CallSpool-CallFile.md | 4 +-- ...PAGI-ChannelVariables-IChannelVariables.md | 26 +++++++++++++++++ ...elVariables-Impl-ChannelVariablesFacade.md | 28 +++++++++++++++++++ doc/PAGI-Client-AbstractClient.md | 2 +- doc/PAGI-Client-Impl-ClientImpl.md | 2 +- doc/PAGI-Client-Impl-MockedClientImpl.md | 2 +- doc/PAGI-Node-MockedNode.md | 4 +-- doc/PAGI-Node-Node.md | 4 +-- 8 files changed, 63 insertions(+), 9 deletions(-) diff --git a/doc/PAGI-CallSpool-CallFile.md b/doc/PAGI-CallSpool-CallFile.md index ea8a7ec..00db558 100644 --- a/doc/PAGI-CallSpool-CallFile.md +++ b/doc/PAGI-CallSpool-CallFile.md @@ -512,7 +512,7 @@ file_get_contents() or similar).</p> ### __construct - void PAGI\CallSpool\CallFile::__construct(\PAGI\DialDescriptor\DialDescriptor $dialDescriptor) + void PAGI\CallSpool\CallFile::__construct(\PAGI\CallSpool\PAGI\DialDescriptor\DialDescriptor $dialDescriptor) Constructor. @@ -522,6 +522,6 @@ Constructor. #### Arguments -* $dialDescriptor **[PAGI\DialDescriptor\DialDescriptor](PAGI-DialDescriptor-DialDescriptor.md)** +* $dialDescriptor **PAGI\CallSpool\PAGI\DialDescriptor\DialDescriptor** - <p>dial descriptor</p> diff --git a/doc/PAGI-ChannelVariables-IChannelVariables.md b/doc/PAGI-ChannelVariables-IChannelVariables.md index 1b4e035..ef14041 100644 --- a/doc/PAGI-ChannelVariables-IChannelVariables.md +++ b/doc/PAGI-ChannelVariables-IChannelVariables.md @@ -463,3 +463,29 @@ Uses environment variable AST_RUN_DIR. + +### getNetworkScript + + string PAGI\ChannelVariables\IChannelVariables::getNetworkScript() + +Returns agi_network_script. + + + +* Visibility: **public** + + + + +### getNetwork + + string PAGI\ChannelVariables\IChannelVariables::getNetwork() + +Returns agi_network. + + + +* Visibility: **public** + + + diff --git a/doc/PAGI-ChannelVariables-Impl-ChannelVariablesFacade.md b/doc/PAGI-ChannelVariables-Impl-ChannelVariablesFacade.md index a91d857..4f5c7af 100644 --- a/doc/PAGI-ChannelVariables-Impl-ChannelVariablesFacade.md +++ b/doc/PAGI-ChannelVariables-Impl-ChannelVariablesFacade.md @@ -554,3 +554,31 @@ Constructor. * $arguments **array<mixed,string>** - <p>AGI arguments given by asterisk (agi_arg_N).</p> + +### getNetworkScript + + string PAGI\ChannelVariables\IChannelVariables::getNetworkScript() + +Returns agi_network_script. + + + +* Visibility: **public** +* This method is defined by [PAGI\ChannelVariables\IChannelVariables](PAGI-ChannelVariables-IChannelVariables.md) + + + + +### getNetwork + + string PAGI\ChannelVariables\IChannelVariables::getNetwork() + +Returns agi_network. + + + +* Visibility: **public** +* This method is defined by [PAGI\ChannelVariables\IChannelVariables](PAGI-ChannelVariables-IChannelVariables.md) + + + diff --git a/doc/PAGI-Client-AbstractClient.md b/doc/PAGI-Client-AbstractClient.md index a9cbd62..0ef904d 100644 --- a/doc/PAGI-Client-AbstractClient.md +++ b/doc/PAGI-Client-AbstractClient.md @@ -20,7 +20,7 @@ Properties ### $logger - protected \PAGI\Client\Logger $logger + protected \Psr\Log\LoggerInterface $logger PSR-3 logger. diff --git a/doc/PAGI-Client-Impl-ClientImpl.md b/doc/PAGI-Client-Impl-ClientImpl.md index 6e9401f..d22b20a 100644 --- a/doc/PAGI-Client-Impl-ClientImpl.md +++ b/doc/PAGI-Client-Impl-ClientImpl.md @@ -54,7 +54,7 @@ AGI output ### $logger - protected \PAGI\Client\Logger $logger + protected \Psr\Log\LoggerInterface $logger PSR-3 logger. diff --git a/doc/PAGI-Client-Impl-MockedClientImpl.md b/doc/PAGI-Client-Impl-MockedClientImpl.md index 22adbb5..296b830 100644 --- a/doc/PAGI-Client-Impl-MockedClientImpl.md +++ b/doc/PAGI-Client-Impl-MockedClientImpl.md @@ -42,7 +42,7 @@ Mocked result strings. ### $logger - protected \PAGI\Client\Logger $logger + protected \Psr\Log\LoggerInterface $logger PSR-3 logger. diff --git a/doc/PAGI-Node-MockedNode.md b/doc/PAGI-Node-MockedNode.md index 7f8d1c1..d18b3f9 100644 --- a/doc/PAGI-Node-MockedNode.md +++ b/doc/PAGI-Node-MockedNode.md @@ -1500,7 +1500,7 @@ Returns the kind of digit entered by the user, CANCEL, END, NORMAL. ### acceptInput - void PAGI\Node\Node::acceptInput($digit) + void PAGI\Node\Node::acceptInput(\PAGI\Node\@param $digit) Process a single digit input by the user. Changes the node state according to the digit entered (CANCEL, COMPLETE). @@ -1512,7 +1512,7 @@ according to the digit entered (CANCEL, COMPLETE). #### Arguments -* $digit **mixed** +* $digit **PAGI\Node\@param** - <p>string $digit A single character, one of the DTMF_* constants.</p> diff --git a/doc/PAGI-Node-Node.md b/doc/PAGI-Node-Node.md index 7ec5e58..4a66ed9 100644 --- a/doc/PAGI-Node-Node.md +++ b/doc/PAGI-Node-Node.md @@ -1119,7 +1119,7 @@ Returns the kind of digit entered by the user, CANCEL, END, NORMAL. ### acceptInput - void PAGI\Node\Node::acceptInput($digit) + void PAGI\Node\Node::acceptInput(\PAGI\Node\@param $digit) Process a single digit input by the user. Changes the node state according to the digit entered (CANCEL, COMPLETE). @@ -1130,7 +1130,7 @@ according to the digit entered (CANCEL, COMPLETE). #### Arguments -* $digit **mixed** +* $digit **PAGI\Node\@param** - <p>string $digit A single character, one of the DTMF_* constants.</p>