diff --git a/.travis.yml b/.travis.yml index 2052749a2..2f30e1641 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,32 @@ language: php -php: - - '5.4' - - '5.5' - - '5.6' - - '7.0' +jobs: + include: + - php: 5.4 + dist: trusty + - php: 5.5 + dist: trusty + - php: 5.6 + dist: xenial + - php: 7.0 + dist: xenial + - php: 7.1 + dist: xenial + - php: 7.2 + dist: xenial + - php: 7.3 + dist: xenial + - php: 7.4 + dist: xenial + - php: 8.0 + dist: focal + before_script: - phpenv config-add test/resources/php.ini install: - - composer install + - composer install || composer install --ignore-platform-reqs + - if [[ ${TRAVIS_PHP_VERSION:0:1} == "8" ]]; then sh test/resources/compatibility-php8.sh; fi script: - vendor/bin/phing travis @@ -20,4 +37,4 @@ after_script: addons: code_climate: - repo_token: 5d81d5163c7f9b810b46451042cb0069d24c91a5887466ba774bf89a56f0187e \ No newline at end of file + repo_token: 5d81d5163c7f9b810b46451042cb0069d24c91a5887466ba774bf89a56f0187e diff --git a/README.md b/README.md index 0be4e82b9..dbabe8384 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ # Introduction -PAMI means PHP Asterisk Manager Interface. As its name suggests its just a +PAMI means PHP Asterisk Manager Interface. As its name suggests its a set of php classes that will let you issue commands to an ami and/or receive events, using an observer-listener pattern. -The idea behind this, is to easily implement operator consoles, monitors, etc. -either via SOA or ajax. +The idea behind this, is to easily implement operator consoles, monitors, +real time telephone applications, etc. either via SOA or ajax. A port for nodejs is available at: http://marcelog.github.com/Nami A port for erlang is available at: https://github.com/marcelog/erlami @@ -28,17 +28,24 @@ A port for erlang is available at: https://github.com/marcelog/erlami # PHP Versions +## PHP 5 Note: PAMI Requires PHP 5.3+. PHP versions 5.3.9 and 5.3.10 WILL NOT WORK due to a bug introduced in stream_get_line() in 5.3.9. Please use 5.3.11+ or up to 5.3.8 (see README.PHP-5.3.9-and-5.3.10). +Also running on 5.4 and 5.5. + +## PHP 7 +PHP Versions 7.0, 7.1, 7.2, 7.3 and 7.4 are also confirmed working with +the latest version. + +## PHP 8 +This version is also supported. # Installing Add this library to your [Composer](https://packagist.org/) configuration. In composer.json: -```json - "require": { - "marcelog/pami": "2.*" - } +```sh +composer require marcelog/pami ``` # QuickStart @@ -97,7 +104,8 @@ Also, you might want to look at this article: http://marcelog.github.com/article For an example of using asynchronous AGI with PAMI, see docs/examples/asyncagi -The [march edition](http://sdjournal.org/a-practical-introduction-to-functional-programming-with-php-sdj-issue-released/) of [Software Developer Journal](http://sdjournal.org/) features a complete article about writing telephony applications with PAMI and PAGI. +The [2014 march edition](http://web.archive.org/web/20140625083045/http://sdjournal.org/a-practical-introduction-to-functional-programming-with-php-sdj-issue-released/) +of [Software Developer Journal](http://sdjournal.org/) features a complete article about writing telephony applications with PAMI and PAGI. # Currently Supported Events diff --git a/composer.json b/composer.json index 83e4c798d..411dbf1dd 100644 --- a/composer.json +++ b/composer.json @@ -23,16 +23,16 @@ "psr/log": ">= 1.0.0" }, "require-dev": { - "phpunit/phpunit": "4.*", + "phpunit/phpunit": "4.8.36", "monolog/monolog": "1.*", - "squizlabs/php_codesniffer": "2.*", + "squizlabs/php_codesniffer": "2.*|3.*", "phpdocumentor/phpdocumentor": "2.*", - "phing/phing": "2.*", + "phing/phing": "2.16.3", "phpmd/phpmd": "2.*", "satooshi/php-coveralls": "1.0.1", "evert/phpdoc-md" : "~0.1.1", "codeclimate/php-test-reporter": "dev-master", - "sebastian/phpcpd": "*", + "sebastian/phpcpd": "2.0.4", "marcelog/pagi": "2.*" } } diff --git a/src/PAMI/Message/Event/CdrEvent.php b/src/PAMI/Message/Event/CdrEvent.php new file mode 100644 index 000000000..de94cc557 --- /dev/null +++ b/src/PAMI/Message/Event/CdrEvent.php @@ -0,0 +1,213 @@ + + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Event; + +use PAMI\Message\Event\EventMessage; + +/** + * Event triggered when a channel changes its status. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Event + * @author Marcelo Gornstein + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class CdrEvent extends EventMessage +{ + /** + * Returns key: 'UniqueID'. + * + * @return string + */ + public function getUniqueID() + { + return $this->getKey('UniqueID'); + } + + /** + * Returns key: 'Privilege'. + * + * @return string + */ + public function getPrivilege() + { + return $this->getKey('Privilege'); + } + /** + * Returns key: 'AccountCode'. + * + * @return string + */ + public function getAccountCode() + { + return $this->getKey('AccountCode'); + } + /** + * Returns key: 'Source'. + * + * @return string + */ + public function getSource() + { + return $this->getKey('Source'); + } + /** + * Returns key: 'Destination'. + * + * @return string + */ + public function getDestination() + { + return $this->getKey('Destination'); + } + /** + * Returns key: 'DestinationContext'. + * + * @return string + */ + public function getDestinationContext() + { + return $this->getKey('DestinationContext'); + } + /** + * Returns key: 'CallerID'. + * + * @return string + */ + public function getCallerID() + { + return $this->getKey('CallerID'); + } + /** + * Returns key: 'Channel'. + * + * @return string + */ + public function getChannel() + { + return $this->getKey('Channel'); + } + /** + * Returns key: 'DestinationChannel'. + * + * @return string + */ + public function getDestinationChannel() + { + return $this->getKey('DestinationChannel'); + } + /** + * Returns key: 'LastApplication'. + * + * @return string + */ + public function getLastApplication() + { + return $this->getKey('LastApplication'); + } + /** + * Returns key: 'LastData'. + * + * @return string + */ + public function getLastData() + { + return $this->getKey('LastData'); + } + /** + * Returns key: 'StartTime'. + * + * @return string + */ + public function getStartTime() + { + return $this->getKey('StartTime'); + } + /** + * Returns key: 'AnswerTime'. + * + * @return string + */ + public function getAnswerTime() + { + return $this->getKey('AnswerTime'); + } + /** + * Returns key: 'EndTime'. + * + * @return string + */ + public function getEndTime() + { + return $this->getKey('EndTime'); + } + /** + * Returns key: 'Duration'. + * + * @return string + */ + public function getDuration() + { + return $this->getKey('Duration'); + } + /** + * Returns key: 'BillableSeconds'. + * + * @return string + */ + public function getBillableSeconds() + { + return $this->getKey('BillableSeconds'); + } + /** + * Returns key: 'Disposition'. + * + * @return string + */ + public function getDisposition() + { + return $this->getKey('Disposition'); + } + /** + * Returns key: 'AMAFlags'. + * + * @return string + */ + public function getAMAFlags() + { + return $this->getKey('AMAFlags'); + } +} \ No newline at end of file diff --git a/test/actions/Test_Actions.php b/test/actions/Test_Actions.php index 28f9138df..103fd5083 100644 --- a/test/actions/Test_Actions.php +++ b/test/actions/Test_Actions.php @@ -41,7 +41,7 @@ * @license http://marcelog.github.com/ Apache License 2.0 * @link http://marcelog.github.com/ */ -class Test_Actions extends \PHPUnit_Framework_TestCase +class Test_Actions extends \PHPUnit\Framework\TestCase { private $_properties = array(); diff --git a/test/client/Test_Client.php b/test/client/Test_Client.php index feec27b9f..f0bd9ca83 100644 --- a/test/client/Test_Client.php +++ b/test/client/Test_Client.php @@ -189,7 +189,7 @@ function setFgetsMock(array $readValues, $writeValues) * @license http://marcelog.github.com/ Apache License 2.0 * @link http://marcelog.github.com/ */ -class Test_Client extends \PHPUnit_Framework_TestCase +class Test_Client extends \PHPUnit\Framework\TestCase { private $_properties = array(); @@ -256,7 +256,7 @@ public function can_detect_other_peer() 'connect_timeout' => 10, 'read_timeout' => 10 ); - $read = array('Whatever'); + $read = array("Whatever"); $write = array(); setFgetsMock($read, $write); $client = new \PAMI\Client\Impl\ClientImpl($options); diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 580fccd13..9c2e95936 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -40,7 +40,7 @@ * @license http://marcelog.github.com/ Apache License 2.0 * @link http://marcelog.github.com/ */ -class Test_Events extends \PHPUnit_Framework_TestCase +class Test_Events extends \PHPUnit\Framework\TestCase { private $_properties = array(); diff --git a/test/resources/compatibility-php8.sh b/test/resources/compatibility-php8.sh new file mode 100644 index 000000000..e7d1e5fb2 --- /dev/null +++ b/test/resources/compatibility-php8.sh @@ -0,0 +1,18 @@ + +#!/bin/sh + +# require new version of phpunit and phpcpd, as the old ones are incompatible with php8 +# (note: cannot generally require the new ones as these are not compatible with php 5) +composer require phpunit/phpunit:8.* sebastian/phpcpd:* --ignore-platform-reqs --with-all-dependencies + +# disable cpd for now, as newer version fails with duplicated code +sed -i 's/, cpd//g' build.xml + +# phpunit compatiblity of new versions (requires return type declaration) +sed -i 's/function setUp()/function setUp() : void/g' test/*/*.php + +# phpunit xml compatiblity, delete deprecated flag +sed -i 's/mapTestClassNameToCoveredClassName="false"//g' test/resources/phpunit.xml + +# phpunit disable stop on risky, as risky test functions are being used +sed -i 's/stopOnRisky="true"//g' test/resources/phpunit.xml diff --git a/test/resources/php.ini b/test/resources/php.ini index 2e67c2995..125753398 100644 --- a/test/resources/php.ini +++ b/test/resources/php.ini @@ -1 +1,2 @@ -date.timezone = "UTC" \ No newline at end of file +date.timezone = "UTC" +xdebug.mode = "coverage"