An AGI client implementation useful for mocking and testing ivr apps.
PHP Version 5
- Class name: MockedClientImpl
- Namespace: PAGI\Client\Impl
- Parent class: PAGI\Client\AbstractClient
private array<mixed,string> $mockedResultStrings
Mocked result strings.
- Visibility: private
private mixed $methodCallAsserts = array()
- Visibility: private
protected \Psr\Log\LoggerInterface $logger
PSR-3 logger.
- Visibility: protected
protected array<mixed,string> $variables = array()
Initial channel variables given by asterisk at start.
- Visibility: protected
protected array<mixed,string> $arguments = array()
Initial arguments given by the user in the dialplan.
- Visibility: protected
protected mixed $cdrInstance = false
- Visibility: protected
protected mixed $channelVariablesInstance = false
- Visibility: protected
protected mixed $clidInstance = false
- Visibility: protected
\PAGI\Client\Result\Result PAGI\Client\AbstractClient::send(string $text)
Sends a command to asterisk. Returns an array with: [0] => AGI Result (3 digits) [1] => Command result [2] => Result data.
- Visibility: protected
- This method is abstract.
- This method is defined by PAGI\Client\AbstractClient
- $text string - <p>Command</p>
void PAGI\Client\AbstractClient::open()
Opens connection to agi. Will also read initial channel variables given by asterisk when launching the agi.
- Visibility: protected
- This method is abstract.
- This method is defined by PAGI\Client\AbstractClient
void PAGI\Client\AbstractClient::close()
Closes the connection to agi.
- Visibility: protected
- This method is abstract.
- This method is defined by PAGI\Client\AbstractClient
mixed PAGI\Client\Impl\MockedClientImpl::__destruct()
- Visibility: public
mixed PAGI\Client\Impl\MockedClientImpl::addMockedResult($string)
- Visibility: public
- $string mixed
mixed PAGI\Client\Impl\MockedClientImpl::assert($methodName, array $args)
- Visibility: public
- $methodName mixed
- $args array
mixed PAGI\Client\Impl\MockedClientImpl::assertCall($methodName, array $arguments)
- Visibility: private
- $methodName mixed
- $arguments array
integer PAGI\Client\IClient::channelStatus(string $channel)
Retrieves channel status. Uses agi command "CHANNEL STATUS"
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $channel string - <p>Optional, channel name.</p>
\PAGI\Client\Result\DigitReadResult PAGI\Client\IClient::waitDigit(integer $timeout)
Waits up to milliseconds for channel to receive a DTMF digit.
Uses agi command "WAIT FOR DIGIT".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $timeout integer - <p>Milliseconds to wait. -1 to block indefinitely.</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::streamFile(string $file, string $escapeDigits)
Plays a file, can be interrupted by escapeDigits.
Uses agi command "STREAM FILE"
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $file string - <p>File to play, without .wav extension.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
\PAGI\Client\Result\DialResult PAGI\Client\IClient::dial(string $channel, array<mixed,string> $options)
Tries to dial the given channel.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $channel string - <p>What to dial.</p>
- $options array<mixed,string> - <p>Dial app options</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::getData(string $file, integer $maxTime, string $maxDigits)
Reads input from user. Uses agi command "GET DATA".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $file string - <p>File to play.</p>
- $maxTime integer - <p>Maximum time between digits before timeout.</p>
- $maxDigits string - <p>Maximum number of digits expected.</p>
\PAGI\Client\Result\RecordResult PAGI\Client\IClient::record(string $file, string $format, string $escapeDigits, integer $maxRecordTime, integer $silence)
Record to a file until are received as dtmf.
Uses agi command "RECORD FILE".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $file string - <p>Target file, without the .wav (or extension chosen).</p>
- $format string - <p>Format (wav, mp3, etc).</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
- $maxRecordTime integer - <p>Maximum record time (optional).</p>
- $silence integer - <p>Maximum time of silence allowed (optional)</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::sayTime(integer $time, string $escapeDigits)
Says time. Uses agi command "SAY TIME".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $time integer - <p>Unix timestamp.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::sayDate(integer $time, string $escapeDigits)
Say a given date, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY DATE".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $time integer - <p>Unix timestamp.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::sayDateTime(integer $time, string $format, string $escapeDigits)
Say a given date and time, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY DATETIME".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $time integer - <p>Unix timestamp.</p>
- $format string - <p>Format the time should be said in.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::sayDigits(string $digits, string $escapeDigits)
Says digits. Uses agi command "SAY DIGITS".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $digits string - <p>Number to say.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::sayNumber(string $digits, string $escapeDigits)
Says a number. Uses agi command "SAY NUMBER".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $digits string - <p>Number to say.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::sayAlpha(string $what, string $escapeDigits)
Say a given character string, returning early if any of the given DTMF digits are received on the channel. Uses agi command "SAY PHONETIC".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $what string - <p>What to say.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::sayPhonetic(string $what, string $escapeDigits)
Say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel.
Uses agi command "SAY PHONETIC".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $what string - <p>What to say.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
string PAGI\Client\IClient::getFullVariable(string $name, string $channel)
Returns a variable value. Uses agi command "GET FULL VARIABLE". False if variable is not set.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string - <p>Variable name.</p>
- $channel string - <p>Optional channel name.</p>
string PAGI\Client\IClient::getVariable(string $name)
Returns a variable value. Uses agi command "GET VARIABLE". False if variable is not set.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string - <p>Variable name.</p>
void PAGI\Client\IClient::setVariable(string $name, string $value)
Sets a variable. Uses agi command "SET VARIABLE".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string - <p>Variable name.</p>
- $value string - <p>Variable value.</p>
void PAGI\Client\IClient::consoleLog(string $msg)
Logs to asterisk console. Uses agi command "VERBOSE".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $msg string - <p>Message to log.</p>
void PAGI\Client\IClient::log(string $msg, string $priority)
Logs to asterisk logger. Uses application LOG.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $msg string - <p>Message to log.</p>
- $priority string - <p>One of ERROR, WARNING, NOTICE, DEBUG, VERBOSE, DTMF</p>
\PAGI\Client\Result\PlayResult PAGI\Client\IClient::getOption(string $file, string $escapeDigits, integer $maxTime)
Reads input from user. Uses agi command "GET OPTION".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $file string - <p>File to play.</p>
- $escapeDigits string - <p>Optional sequence of digits that can be used to skip the sound.</p>
- $maxTime integer - <p>Maximum time between digits before timeout.</p>
void PAGI\Client\IClient::setCallerId(string $name, string $number)
Changes the callerid of the current channel. Uses agi command "SET CALLERID"
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string - <p>CallerId name.</p>
- $number string - <p>CallerId number.</p>
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::playBusyTone()
Plays "Busy" tone, defined in indications.conf
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::playCongestionTone()
Plays "Congestion" tone, defined in indications.conf
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::playDialTone()
Plays "Dial" tone, defined in indications.conf
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::stopPlayingTones()
Stop playing current played tones.
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::playCustomTones(array<mixed,string> $frequencies)
Plays a customized frequency tone.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $frequencies array<mixed,string> - <p>Frequencies for the tone: 425/50,0/50 or !950/330,!1400/330,!1800/330,0 etc.</p>
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::playTone(string $tone)
Plays a tone defined in indications.conf.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $tone string - <p>Tone to play</p>
void PAGI\Client\IClient::setPriority(string $priority)
Changes the priority for continuation upon exiting the application.
Uses agi command "SET PRIORITY".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $priority string - <p>New priority.</p>
void PAGI\Client\IClient::setContext(string $context)
Changes the context for continuation upon exiting the application.
Uses agi command "SET CONTEXT".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $context string - <p>New context.</p>
void PAGI\Client\IClient::setExtension(string $extension)
Changes the extension for continuation upon exiting the application.
Uses agi command "SET EXTENSION".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $extension string - <p>New extension.</p>
void PAGI\Client\IClient::setMusic(boolean $enable, string $class)
Enables/Disables the music on hold generator. Uses agi command "SET MUSIC".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $enable boolean - <p>True to enable, false to disable.</p>
- $class string - <p>If <class> is not specified then the default music on hold class will be used.</p>
\PAGI\Client\Result\AmdResult PAGI\Client\IClient::amd(array<mixed,string> $options)
Runs the AMD() application. For a complete list of options see: https://wiki.asterisk.org/wiki/display/AST/Application_AMD
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $options array<mixed,string>
void PAGI\Client\IClient::answer()
Answers the current channel. Uses agi command "ANSWER".
- Visibility: public
- This method is defined by PAGI\Client\IClient
void PAGI\Client\IClient::hangup()
Hangups the current channel. Uses agi command "HANGUP".
- Visibility: public
- This method is defined by PAGI\Client\IClient
mixed PAGI\Client\Impl\MockedClientImpl::onGetOption($interrupted, $digit, $offset)
- Visibility: public
- $interrupted mixed
- $digit mixed
- $offset mixed
mixed PAGI\Client\Impl\MockedClientImpl::onWaitDigit($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onGetVariable($success, $value)
- Visibility: public
- $success mixed
- $value mixed
mixed PAGI\Client\Impl\MockedClientImpl::onGetFullVariable($success, $value)
- Visibility: public
- $success mixed
- $value mixed
mixed PAGI\Client\Impl\MockedClientImpl::onChannelStatus($status)
- Visibility: public
- $status mixed
mixed PAGI\Client\Impl\MockedClientImpl::onDial($success, $peerName, $peerNumber, $answeredTime, $dialStatus, $dynamicFeatures)
- Visibility: public
- $success mixed
- $peerName mixed
- $peerNumber mixed
- $answeredTime mixed
- $dialStatus mixed
- $dynamicFeatures mixed
mixed PAGI\Client\Impl\MockedClientImpl::onRecord($interrupted, $hangup, $digit, $endpos)
- Visibility: public
- $interrupted mixed
- $hangup mixed
- $digit mixed
- $endpos mixed
mixed PAGI\Client\Impl\MockedClientImpl::onStreamFile($interrupted, $digit, $offset)
- Visibility: public
- $interrupted mixed
- $digit mixed
- $offset mixed
mixed PAGI\Client\Impl\MockedClientImpl::onGetData($interrupted, $digits)
- Visibility: public
- $interrupted mixed
- $digits mixed
mixed PAGI\Client\Impl\MockedClientImpl::onSayTime($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onSayDateTime($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onSayDate($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onSayNumber($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onSayDigits($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onSayPhonetic($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onSayAlpha($interrupted, $digit)
- Visibility: public
- $interrupted mixed
- $digit mixed
mixed PAGI\Client\Impl\MockedClientImpl::onAnswer($success)
- Visibility: public
- $success mixed
mixed PAGI\Client\Impl\MockedClientImpl::onHangup($success)
- Visibility: public
- $success mixed
mixed PAGI\Client\Impl\MockedClientImpl::onAmd($status, $cause)
- Visibility: public
- $status mixed
- $cause mixed
mixed PAGI\Client\Impl\MockedClientImpl::onCreateNode($name)
- Visibility: public
- $name mixed
\PAGI\Node\Node PAGI\Client\IClient::createNode(string $name)
Convenient method to create a node.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string
\PAGI\Logger\Asterisk\IAsteriskLogger PAGI\Client\IClient::getAsteriskLogger()
Returns an asterisk logger facade.
- Visibility: public
- This method is defined by PAGI\Client\IClient
mixed PAGI\Client\Impl\MockedClientImpl::getLogger()
- Visibility: public
mixed PAGI\Client\Impl\MockedClientImpl::__construct(array $options)
- Visibility: public
- $options array
\PAGI\Client\Result\Result PAGI\Client\AbstractClient::getResultFromResultString(\PAGI\Client\unknown_type $text)
Returns a result object given a string (the agi result after executing a command).
- Visibility: protected
- This method is defined by PAGI\Client\AbstractClient
- $text PAGI\Client\unknown_type
\PAGI\Client\Result\FaxResult PAGI\Client\IClient::faxSend(string $tiffFile)
Sends a fax.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $tiffFile string - <p>Absolute path to a .tiff file.</p>
\PAGI\Client\Result\FaxResult PAGI\Client\IClient::faxReceive(string $tiffFile)
Receives a fax.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $tiffFile string - <p>Absolute path to a .tiff file.</p>
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::exec(string $application, array<mixed,string> $options)
Executes an application. Uses agi command "EXEC".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $application string - <p>Application name.</p>
- $options array<mixed,string> - <p>Application arguments.</p>
void PAGI\Client\IClient::setAutoHangup(integer $time)
Cause the channel to automatically hangup at seconds in the future.
Of course it can be hungup before then as well. Setting to 0 will cause the autohangup feature to be disabled on this channel. Uses agi command "SET AUTOHANGUP".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $time integer - <p>Time to hangup channel.</p>
mixed PAGI\Client\AbstractClient::playAndRead($cmd)
- Visibility: private
- This method is defined by PAGI\Client\AbstractClient
- $cmd mixed
void PAGI\Client\IClient::databaseDel(string $family, string $key)
Deletes an entry in the Asterisk database for a given family and key.
Uses agi command "DATABASE DEL".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $family string - <p>Family for key.</p>
- $key string - <p>Key name.</p>
void PAGI\Client\IClient::databaseDeltree(string $family, string $key)
Deletes a family or specific keytree withing a family in the Asterisk database.
Uses agi command "DATABASE DELTREE".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $family string - <p>Family for key.</p>
- $key string - <p>Optional key name.</p>
string PAGI\Client\IClient::databaseGet(string $family, string $key)
Retrieves an entry in the Asterisk database for a given family and key.
Uses agi command "DATABASE GET".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $family string - <p>Family for key.</p>
- $key string - <p>Key name.</p>
void PAGI\Client\IClient::databasePut(string $family, string $key, string $value)
Adds or updates an entry in the Asterisk database for a given family, key, and value.
Uses agi command "DATABASE PUT".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $family string - <p>Family for key.</p>
- $key string - <p>Key name.</p>
- $value string - <p>Value to set.</p>
void PAGI\Client\IClient::sendText(string $text)
Sends the given text on a channel. Uses agi command "SEND TEXT".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $text string - <p>Text to send.</p>
void PAGI\Client\IClient::sendImage(string $filename)
Sends the given image on a channel. Uses agi command "SEND IMAGE".
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $filename string - <p>Image absolute path to send.</p>
boolean PAGI\Client\AbstractClient::isEndOfEnvironmentVariables(string $line)
Returns true if the current line marks the end of the environment variables.
- Visibility: protected
- This method is defined by PAGI\Client\AbstractClient
- $line string
void PAGI\Client\AbstractClient::readEnvironmentVariable(string $line)
Will read and save an environment variable as either a variable or an argument.
- Visibility: protected
- This method is defined by PAGI\Client\AbstractClient
- $line string
\PAGI\ChannelVariables\IChannelVariables PAGI\Client\IClient::getChannelVariables()
Returns an instance of ChannelVariables to access agi variables.
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\CDR\ICDR PAGI\Client\IClient::getCDR()
Returns a cdr facade.
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\Client\ICallerID PAGI\Client\IClient::getCallerId()
Returns a caller id facade.
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::indicateProgress()
Indicates progress of a call, starting early audio.
- Visibility: public
- This method is defined by PAGI\Client\IClient
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::indicateBusy(integer $timeout)
Indicates busy and waits for hangup. Does not play a busy tone.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $timeout integer - <p>Time in seconds to wait for hangup</p>
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::indicateCongestion(integer $timeout)
Indicates congestion and waits for hangup. Does not play a busy tone.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $timeout integer - <p>Time in seconds to wait for hangup</p>
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::sipHeaderAdd(string $name, string $value)
Adds a SIP header to the first invite message in a dial command.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string
- $value string
\PAGI\Client\Result\ExecResult PAGI\Client\IClient::sipHeaderRemove(string $name)
Removes a header previously added with sipHeaderAdd.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string
\PAGI\Node\NodeController PAGI\Client\IClient::createNodeController(string $name)
Creates a new node controller.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $name string
void PAGI\Client\IClient::setLogger(\PAGI\Client\Psr\Log\LoggerInterface $logger)
Sets the logger implementation.
- Visibility: public
- This method is defined by PAGI\Client\IClient
- $logger PAGI\Client\Psr\Log\LoggerInterface - <p>The PSR3-Logger</p>