\KorbaUtil

Class Util is a helper class.

A class with function and constant to help easily create USSD. The USSD provider is TxtGhana and the consumer is Korba

Summary

Methods
Properties
Constants
codeToNetwork()
random()
numberGHFormat()
numberIntFormat()
number233Format()
processBack()
processNext()
processPrevious()
processReset()
processBeginning()
verifyPhoneNumber()
verifyNumberLength()
verifyWholeNumber()
verifyAmount()
verifyNumber()
requestToHashedMapArray()
isInitialRequest()
isContinuingRequest()
getRequestSessionId()
parseHistoryToArray()
parseResponseToArray()
appendHistory()
reverse()
redirect()
No public properties found
TERMINATION_CODE
CONTINUE_CODE
No protected methods found
No protected properties found
N/A
__construct()
No private properties found
N/A

Constants

TERMINATION_CODE

TERMINATION_CODE

CONTINUE_CODE

CONTINUE_CODE

Methods

codeToNetwork()

codeToNetwork(string  $code) : string|null

Util public static function codeToNetwork.

It converts TxtGh network code to Korba network code

Parameters

string $code

TxtGhana Code

Returns

string|null

random()

random() : string

Util public static function random.

It generates random ids

Returns

string

numberGHFormat()

numberGHFormat(string  $int_number) : string

Util public static function numberGHFormat.

It convert phone numbers to Ghana Phone Number Format

Parameters

string $int_number

Number to convert

Returns

string

numberIntFormat()

numberIntFormat(string  $gh_number) : string

Util public static function numberIntFormat.

It convert phone numbers to the Internation Number Format

Parameters

string $gh_number

Number to convert

Returns

string

number233Format()

number233Format(string  $number) : string

Util public static function number233Format.

It convert phone numbers to the 233 Number Format

Parameters

string $number

Number to convert

Returns

string

processBack()

processBack(string  $key, string  $value, array<mixed,array>  $history, string  $option) 

Util public static function processBack.

It allows for ussd to move to previous menu

Parameters

string $key
string $value
array<mixed,array> $history
string $option

processNext()

processNext(string  $key, string  $value, string  $target, array<mixed,array>  $history, string  $option) 

Util public static function processNext.

It allows ussd to move to next page on a menu

Parameters

string $key
string $value
string $target
array<mixed,array> $history
string $option

processPrevious()

processPrevious(string  $key, string  $value, string  $target, array<mixed,array>  $history, string  $option) 

Util public static function processPrevious.

It allows ussd to move to previous page on a menu

Parameters

string $key
string $value
string $target
array<mixed,array> $history
string $option

processReset()

processReset(array<mixed,string>  $keys, string  $value, integer  $target) 

Util public static function processReset.

It allows the index of pages of menus to be reset after navigating it

Parameters

array<mixed,string> $keys
string $value
integer $target

processBeginning()

processBeginning(string  $key, string  $value, array<mixed,array>  $history, string  $option) 

Util public static function processBeginning.

It allows ussd to move to first menu

Parameters

string $key
string $value
array<mixed,array> $history
string $option

verifyPhoneNumber()

verifyPhoneNumber(string  $number) : boolean

Util public static function verifyPhoneNumber.

It verifies if a number is correct

Parameters

string $number

Returns

boolean

verifyNumberLength()

verifyNumberLength(string  $number, integer  $length = 10) : boolean

Util public static function verifyNumberLength.

It verifies if a number is exactly a particular length

Parameters

string $number

Number String to verify

integer $length

Length to use for validation

Returns

boolean

verifyWholeNumber()

verifyWholeNumber(string  $number) : boolean

Util public static function verifyWholeNumber.

It verifies if a number is a positive integer

Parameters

string $number

Returns

boolean

verifyAmount()

verifyAmount(string  $amount) : boolean

Util public static function verifyAmount.

It verifies if amount if a correct value

Parameters

string $amount

Returns

boolean

verifyNumber()

verifyNumber(string  $number) : boolean

Util public static function verifyNumber.

Verifies if number is a single digit number

Parameters

string $number

Returns

boolean

requestToHashedMapArray()

requestToHashedMapArray(  $request, \Korba\View  $response, string  $option = "MAIN_MENU", null|string  $auth = null, null|string  $type = null) : array

Util public static function requestToHashedMapArray.

It convert request to an array that can be stored in a database

Parameters

$request
\Korba\View $response
string $option
null|string $auth
null|string $type

Returns

array

isInitialRequest()

isInitialRequest(  $request) : boolean

Util public static function isInitialRequest.

Check if request in an initial request

Parameters

$request

Returns

boolean

isContinuingRequest()

isContinuingRequest(  $request) : boolean

Util public static function isContinuingRequest.

Check if request indicates continuity

Parameters

$request

Returns

boolean

getRequestSessionId()

getRequestSessionId(  $request) : string

Util public static function getRequestSessionId.

Returns the session id in the request

Parameters

$request

Returns

string

parseHistoryToArray()

parseHistoryToArray(string  $history) : array

Util public static function parseHistoryToArray.

Convert History in database back to php array

Parameters

string $history

Returns

array

parseResponseToArray()

parseResponseToArray(\Korba\View  $response, integer  $code) : array

Util public static function parseResponseToArray.

Converts request to array which can be sent back to operator

Parameters

\Korba\View $response
integer $code

Returns

array

appendHistory()

appendHistory(array  $history, string  $input, string  $option) 

Util public static function appendHistory.

Adds a new entry to history

Parameters

array $history
string $input
string $option

reverse()

reverse(string  $key, string  $value, array<mixed,array>  $history, string  $option, string  $from, string  $to) 

Util public static function reverse.

Move ussd back to point in the past

Parameters

string $key
string $value
array<mixed,array> $history
string $option
string $from
string $to

redirect()

redirect(string  $key, string  $value, string  $new_value, string  $option, string  $from, string  $to) 

Util public static function redirect.

Redirect ussd request from one menu to the other

Parameters

string $key
string $value
string $new_value
string $option
string $from
string $to

__construct()

__construct() 

Util constructor.

This construct prevents creating an instance of the class since it has only static methods and constants.