Change default Exception to proper named Exceptions
Byte: InvalidArgumentException for parameters Image: RunetimeException for cannot write file to system
This commit is contained in:
@@ -37,7 +37,7 @@ class Byte
|
|||||||
* BYTE_FORMAT_ADJUST: sprintf adjusted two 2 decimals
|
* BYTE_FORMAT_ADJUST: sprintf adjusted two 2 decimals
|
||||||
* BYTE_FORMAT_SI: use 1000 instead of 1024
|
* BYTE_FORMAT_SI: use 1000 instead of 1024
|
||||||
* @return string converted byte number (float) with suffix
|
* @return string converted byte number (float) with suffix
|
||||||
* @throws \Exception 1: no valid flag set
|
* @throws \InvalidArgumentException 1: no valid flag set
|
||||||
*/
|
*/
|
||||||
public static function humanReadableByteFormat(string|int|float $bytes, int $flags = 0): string
|
public static function humanReadableByteFormat(string|int|float $bytes, int $flags = 0): string
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ class Byte
|
|||||||
$si = false;
|
$si = false;
|
||||||
}
|
}
|
||||||
if ($flags > 7) {
|
if ($flags > 7) {
|
||||||
throw new \Exception("Invalid flags parameter: $flags", 1);
|
throw new \InvalidArgumentException("Invalid flags parameter: $flags", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// si or normal
|
// si or normal
|
||||||
@@ -119,7 +119,7 @@ class Byte
|
|||||||
* @param int $flags bitwise flag with use space turned on
|
* @param int $flags bitwise flag with use space turned on
|
||||||
* BYTE_FORMAT_SI: use 1000 instead of 1024
|
* BYTE_FORMAT_SI: use 1000 instead of 1024
|
||||||
* @return string|int|float converted value or original value
|
* @return string|int|float converted value or original value
|
||||||
* @throws \Exception 1: no valid flag set
|
* @throws \InvalidArgumentException 1: no valid flag set
|
||||||
*/
|
*/
|
||||||
public static function stringByteFormat(string|int|float $number, int $flags = 0): string|int|float
|
public static function stringByteFormat(string|int|float $number, int $flags = 0): string|int|float
|
||||||
{
|
{
|
||||||
@@ -130,7 +130,7 @@ class Byte
|
|||||||
$si = false;
|
$si = false;
|
||||||
}
|
}
|
||||||
if ($flags != 0 && $flags != 4) {
|
if ($flags != 0 && $flags != 4) {
|
||||||
throw new \Exception("Invalid flags parameter: $flags", 1);
|
throw new \InvalidArgumentException("Invalid flags parameter: $flags", 1);
|
||||||
}
|
}
|
||||||
// matches in regex
|
// matches in regex
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Image
|
|||||||
if (!empty($dummy) && file_exists($filename) && is_file($filename)) {
|
if (!empty($dummy) && file_exists($filename) && is_file($filename)) {
|
||||||
$return_data = $filename;
|
$return_data = $filename;
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception('Could not set dummy return file: ' . $dummy . ' in ' . $filename);
|
throw new \RuntimeException('Could not set dummy return file: ' . $dummy . ' in ' . $filename);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$return_data = $dummy;
|
$return_data = $dummy;
|
||||||
|
|||||||
Reference in New Issue
Block a user