Sorry if this is a dumb question, but in PHP can you use the returning value without casting it to a variable. Example,
INSTEAD OF THIS*
public function isPermissionLevel( $permissionLevel )
{
$result = $this->isString($permissionLevel);
if ($result instanceof PermissionLevelException)
{
throw $result;
}
}
CAN YOU DO SOMETHING LIKE THIS
public function isPermissionLevel( $permissionLevel )
{
if ($this->isString($permissionLevel) instanceof PermissionLevelException)
{
throw // return value i.e. $this->isString($permissionLevel;
}
}
CALLING THIS METHOD
public function isString( $string )
{
try
{
$string = new Stringy( $string );
return (string) $string;
}
catch ( \ InvalidArgumentException $failed )
{
return( new PermissionLevelException( 'Not a valid string . ' . $failed->getMessage() . ' code . ' . $failed->getCode() ) );
}
}