You have two ternary if statements
. Although they look different than traditional if statements, they operate the same way.
Line by line -- This is how this code works:
$environment = ( $this->environment == "yes" ) ? 'TRUE' : 'FALSE';
This is the exact same as
if($this->environment == "yes"){
$environment = 'TRUE';
}else{
$environment = 'FALSE';
}
So now $environment
has been set. Onto the next ternary if
$environment_url = ( "FALSE" == $environment )
? 'https://api.ewaypayments.com/AccessCodes'
: 'https://api.sandbox.ewaypayments.com/AccessCodes';
This is the exact same as this if:
if ($environment == 'FALSE'){
$environment_url = 'https://api.ewaypayments.com/AccessCodes';
}else{
$environment_url = 'https://api.sandbox.ewaypayments.com/AccessCodes';
}
The ?
in the statement indicates to php
that this is a ternary
conditional. The condition
on the left side of the :
is what happens if the statement
returns "positive". The condition
on the right side is what happens if the statement
returns "negative".