PHP code example of wikimedia / normalized-exception
1. Go to this page and download the library: Download wikimedia/normalized-exception library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wikimedia / normalized-exception example snippets
use Wikimedia\NormalizedException\NormalizedException;
throw new NormalizedException( 'Invalid value: {value}', [ 'value' => $value ] );
use Wikimedia\NormalizedException\INormalizedException;
use Wikimedia\NormalizedException\NormalizedExceptionTrait;
class MyException extends SomeException implements INormalizedException {
use NormalizedExceptionTrait;
public function __construct( string $normalizedMessage, array $messageContext = [] ) {
$this->normalizedMessage = $normalizedMessage;
$this->messageContext = $messageContext;
parent::__construct(
self::getMessageFromNormalizedMessage( $normalizedMessage, $messageContext )
);
}
}