ixnode/php-exception

PHP Exception - This library offers some ready to use PHP Exceptions.

0.1.21 2023-07-03 21:13 UTC

This package is auto-updated.

Last update: 2024-04-03 22:49:58 UTC


README

Release PHP PHPStan PHPCS LICENSE

This library offers some ready to use PHP Exceptions.

Exception Classes

Group Array

Array

Name

Parameter

Usage
ArrayKeyNotFoundException string $key Used to indicate that a key in an array does not exist.
ArrayCountException none Used to indicate that two given arrays do not match in size.

Group Case

Case

Name

Parameter

Usage
CaseInvalidException string $given
array $expected
Used to indicate that a specified case is not supported (match, switch, etc.).
CaseUnsupportedException string $case Used to indicate that a specified case is not supported (logic missing things, etc.).

Group Class

Class

Name

Parameter

Usage
ClassInvalidException string $class
string $expected
Used to indicate that a given or passed class is invalid.

Group Configuration

Configuration

Name

Parameter

Usage
ConfigurationMissingException string $hint Used to indicate that a configuration or an action is missing.

Group Db

Db

Name

Parameter

Usage
DbEntityNotFoundException string $class Used to indicate that a db entity was not found.

Group File

File

Name

Parameter

Usage
FileNotFoundException string $path Used to indicate that a given file was not found.
FileNotReadableException string $path Used to indicate that a given file is not readable.
FileNotWriteableException string $path Used to indicate that a file cannot be written.

Group Function

Function

Name

Parameter

Usage
FunctionCurlExecException string $error
string $url
Used to indicate that the curl_exec function is not working properly.
FunctionFOpenException none Used to indicate that the function fopen does not work properly.
FunctionJsonEncodeException none Used to indicate that an object cannot be converted into a JSON string.
FunctionReplaceException string $replacePattern Used to indicate that a value could not be replaced (str_replace, preg_replace, etc.).

Group Parser

Parser

Name

Parameter

Usage
ParserException string $parseString
string $context
Used to indicate that a given string could not be parsed.

Group Type

Type

Name

Parameter

Usage
TypeInvalidException string $expected
?string $given = null
Used to indicate that a given or passed variable is the wrong type.

Installation

composer require ixnode/php-exception
vendor/bin/php-exception -V
php-exception 0.1.0 (12-30-2022 11:41:25) - Björn Hempel <bjoern@hempel.li>

Usage

use Ixnode\PhpException\FileNotFoundException;
throw new FileNotFoundException('path-to-file');

Development

git clone git@github.com:ixnode/php-exception.git && cd php-exception
composer install
composer test

License

This tool is licensed under the MIT License - see the LICENSE file for details