1
|
|
|
<?php |
2
|
|
|
namespace Sender\ExceptionClass; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* This class for Parameter Exception |
6
|
|
|
* |
7
|
|
|
* @package Sender\ExceptionClass\ParameterException |
8
|
|
|
* @author VenkatS <[email protected]> |
9
|
|
|
* @link https://github.com/tesark/msg91-php |
10
|
|
|
* @license MIT |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
class ParameterException extends \Exception |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* This function throw invalid exceptin without message |
17
|
|
|
* @param string $arrName Arrtibute name |
18
|
|
|
* @param string $arrtype Arrtibute type |
19
|
|
|
* @param string $value Acually given value |
20
|
|
|
* |
21
|
|
|
* @return string Exception message |
22
|
|
|
*/ |
23
|
21 |
|
public static function invalidArrtibuteType($arrName, $arrtype, $value) |
24
|
|
|
{ |
25
|
21 |
|
return new static("Invalid Input expect type:\t".$arrtype."\tgiven:\t".gettype($value)."\tparams:".$arrName); |
26
|
|
|
} |
27
|
|
|
/** |
28
|
|
|
* This function throw invalid exceptin with message |
29
|
|
|
* @param string $arrName Arrtibute name |
30
|
|
|
* @param string $arrtype Arrtibute type |
31
|
|
|
* @param string $value Acually given value |
32
|
|
|
* @param string $message Exception message |
33
|
|
|
* |
34
|
|
|
* @return string Exception message |
35
|
|
|
*/ |
36
|
65 |
|
public static function invalidInput($arrName, $arrtype, $value, $message) |
37
|
|
|
{ |
38
|
65 |
|
$message = $arrtype."\tparams:\t".$arrName."\tgiven:\t".gettype($value)."\tReason:\t".$message; |
39
|
65 |
|
return new static("Invalid Input expect type:\t".$message); |
40
|
|
|
} |
41
|
|
|
/** |
42
|
|
|
* This function throw message |
43
|
|
|
* @param string $message |
44
|
|
|
* |
45
|
|
|
* @return string Exception message |
46
|
|
|
*/ |
47
|
14 |
|
public static function missinglogic($message) |
48
|
|
|
{ |
49
|
14 |
|
return new static("Error exception:\t".$message); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|