summaryrefslogtreecommitdiffstats
path: root/src/PCurlException.php
diff options
context:
space:
mode:
authorpurplecode <niespammnie@gmail.com>2013-12-05 08:55:54 +0100
committerpurplecode <niespammnie@gmail.com>2013-12-05 08:55:54 +0100
commit8af62be1a514f322f432076ae0e11390f1907457 (patch)
treeb50ed7bd02a144389d94877a0b71670e2cdcc8e4 /src/PCurlException.php
parent4e3873f02061baf5b1141072479369e84302fcb1 (diff)
downloadphp.curl-8af62be1a514f322f432076ae0e11390f1907457.zip
php.curl-8af62be1a514f322f432076ae0e11390f1907457.tar.gz
php.curl-8af62be1a514f322f432076ae0e11390f1907457.tar.bz2
initial code
Diffstat (limited to 'src/PCurlException.php')
-rw-r--r--src/PCurlException.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/PCurlException.php b/src/PCurlException.php
new file mode 100644
index 0000000..04819f5
--- /dev/null
+++ b/src/PCurlException.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Nsn\NetEng\CommonBundle\Exceptions;
+
+
+class MintException extends \Exception {
+
+ public static function getClassName() {
+ return get_called_class();
+ }
+
+ public static function assert($condition, $message, $arguments = array(), $code = 400) {
+ if (!$condition) {
+ $arguments = array_map('json_encode', ArrayUtils::ensureArray($arguments));
+ $arguments = array_merge(array($message), $arguments);
+ $message = call_user_func_array('sprintf', $arguments);
+ $class = self::getClassName();
+ throw new $class($message, $code);
+ }
+ }
+
+ public function __construct($message = "Exception", $code = 400 $previous = null) {
+ parent::__construct($message, $code, $previous);
+ }
+
+ public function ensureArray($item) {
+ if (is_null($item)) {
+ return array();
+ }
+ return is_array($item) ? $item : array($item);
+ }
+
+} \ No newline at end of file