/** * @covers ::getFields */ public function test_getFields() { $Fields = $this->Exception->getFields(); $this->assertSame('%class%::%func%(%args%):', $Fields['%header%'], 'LogicException::getFields() Returned an invalid value'); $this->assertSame("1, 1.5, 'string', array, stdClass, resource, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'", $Fields['%args%'], 'LogicException::getFields() Returned an invalid value'); $this->assertContains('closure', $Fields['%func%'], 'LogicException::getFields() Returned an invalid value'); $this->assertContains(__FILE__, $Fields['%caused%'], 'LogicException::getFields() Returned an invalid value'); }
/** * Constructor * * @param integer $status * Current status of the class. * @param string $message * Formatted exception string: * * <ul> * <li><b>%header%</b>: <code>class::function(arguments):</code> </li> * <li><b>%status%</b>: Status code of current object.</li> * <li><b>%args%</b>: All arguments as a string.</li> * <li><b>%class%</b>: Class of of function.</li> * <li><b>%func%</b>: Function with invalid argument.</li> * </ul> * * @param integer $code * Exception code. * @param \Exception $previous * Previous Exception. * @return void */ public function __construct($status, $message = null, $code = 0, Exception $previous = null) { if (is_null($message)) { $message = '%header% Current class is currupted. Status: %status%.'; } $Replacements = $this->GetFields(); $message = str_replace(array_keys($Replacements), array_values($Replacements), $message); $message = str_replace('%status%', @strval($status), $message); $message .= $Replacements['%caused%']; parent::__construct($message, $code, $previous); }
/** * Contstructor * * @param integer $argno * The argument that is invalid. * @param string $message * Formatted exception string. * * <ul> * <li><b>%header%</b>: <code>class::function(arguments):</code>.</li> * <li><b>%argno%</b>: Invalid argument position.</li> * <li><b>%args%</b>: All arguments as a string.</li> * <li><b>%class%</b>: Class of of function.</li> * <li><b>%func%</b>: Function with invalid argument.</li> * </ul> * * @param integer $code * Exception code. * @param \Exception $previous * Previous Exception. */ public function __construct($argno, $message = null, $code = 0, Exception $previous = null) { if (is_null($message)) { $message = '%header% Argument %argno% is invalid.'; } $Replacements = $this->GetFields(); $Replacements['%argno%'] = @strval($argno + 1); $message = str_replace(array_keys($Replacements), array_values($Replacements), $message); $message .= $Replacements['%caused%']; parent::__construct($message, $code, $previous); }