O:39:"phpDocumentor\Descriptor\FileDescriptor":22:{s:7:" * hash";s:32:"8e022bd1fc4f350f6215fcaea3939c84";s:7:" * path";s:27:"lib/Utilities/Utilities.php";s:9:" * source";s:2256:"<?php
	
namespace mCASH\Utilities;

/**
 * Abstract Utilities class.
 * 
 * @abstract
 */
abstract class Utilities {

	/**
	 * convertToMCASHObject function.
	 * 
	 * @access public
	 * @static
	 * @param mixed $resp
	 * @param mixed $opts
	 * @return void
	 */
	public static function convertToMCASHObject($resp, $opts){

		$types = array(
			'paymentrequest' 			=> 'mCASH\\PaymentRequest',
			'paymentrequestoutcome' 	=> 'mCASH\\PaymentRequestOutcome',
			'report' 					=> 'mCASH\\Report'
		);
		
		if (is_array($resp) || is_object($resp)) {
			if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
				$class = $types[$resp['object']];
			} else {
				$class = 'mCASH\\mCASHObject';
			}			
			return $class::constructFrom($resp, $opts);
		} else {
			return $resp;
		}
		
	}	

	/**
	 * handleResponseCode function.
	 * 
	 * @access public
	 * @static
	 * @param mixed $code
	 * @param mixed $response (default: null)
	 * @return boolean
	 *
	 * Throws Error\Request
	 * Throws Error\Api
	 */
	public static function handleResponseCode( $code, $response = null ){
		
		// Convert $response from json string to array
		$response = ( empty( $response ) ) ? array() : json_decode( $response, true );

		switch( $code ){
			case 200:
			case 201:
			case 204:
				return true;
				break;
			case 400:
				throw new \mCASH\Error\Request("Illegal input. " . self::handleErrorResponse( $response ) );
				break;
			case 404:
				throw new \mCASH\Error\Api("Object not found. " . self::handleErrorResponse( $response ) );
				break;
			case 405:
				throw new \mCASH\Error\Request("Method not allowed. " . self::handleErrorResponse( $response ) );
				break;
			case 409:
				throw new \mCASH\Error\Request("Conflict. The action might not be legal at this moment, or some data might be duplicated. " . self::handleErrorResponse( $response ) );
				break;
			case 500:
				throw new \mCASH\Error\Request("500 Error. Malformed data. " . self::handleErrorResponse( $response ) );
				break;
		}
	}
	
	public static function handleErrorResponse( $response ){
		
		if( isset( $response['error_type'] ) && isset( $response['error_description'] ) ) return "{$response['error_type']}: {$response['error_description']}";
		
	}
	
}";s:19:" * namespaceAliases";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:11:" * includes";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:12:" * constants";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:12:" * functions";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:10:" * classes";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{s:26:"\mCASH\Utilities\Utilities";O:40:"phpDocumentor\Descriptor\ClassDescriptor":19:{s:9:" * parent";s:0:"";s:13:" * implements";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:11:" * abstract";b:1;s:8:" * final";b:0;s:12:" * constants";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:13:" * properties";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:10:" * methods";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:3:{s:20:"convertToMCASHObject";O:41:"phpDocumentor\Descriptor\MethodDescriptor":17:{s:9:" * parent";r:15;s:11:" * abstract";b:0;s:8:" * final";b:0;s:9:" * static";b:1;s:13:" * visibility";s:6:"public";s:12:" * arguments";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:2:{s:5:"$resp";O:43:"phpDocumentor\Descriptor\ArgumentDescriptor":16:{s:9:" * method";r:27;s:8:" * types";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:51:"phpDocumentor\Descriptor\Type\UnknownTypeDescriptor":1:{s:7:" * name";s:5:"mixed";}}}s:10:" * default";N;s:14:" * byReference";b:0;s:13:" * isVariadic";b:0;s:8:" * fqsen";s:0:"";s:7:" * name";s:5:"$resp";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:0:"";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:0;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}s:5:"$opts";O:43:"phpDocumentor\Descriptor\ArgumentDescriptor":16:{s:9:" * method";r:27;s:8:" * types";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:51:"phpDocumentor\Descriptor\Type\UnknownTypeDescriptor":1:{s:7:" * name";s:5:"mixed";}}}s:10:" * default";N;s:14:" * byReference";b:0;s:13:" * isVariadic";b:0;s:8:" * fqsen";s:0:"";s:7:" * name";s:5:"$opts";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:0:"";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:0;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}}}s:8:" * fqsen";s:50:"\mCASH\Utilities\Utilities::convertToMCASHObject()";s:7:" * name";s:20:"convertToMCASHObject";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:30:"convertToMCASHObject function.";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:21;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:4:{s:6:"access";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:38:"phpDocumentor\Descriptor\TagDescriptor":3:{s:7:" * name";s:6:"access";s:14:" * description";s:6:"public";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:6:"static";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:38:"phpDocumentor\Descriptor\TagDescriptor":3:{s:7:" * name";s:6:"static";s:14:" * description";s:0:"";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:5:"param";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:2:{i:0;O:44:"phpDocumentor\Descriptor\Tag\ParamDescriptor":5:{s:15:" * variableName";s:5:"$resp";s:8:" * types";r:37;s:7:" * name";s:5:"param";s:14:" * description";s:0:"";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}i:1;O:44:"phpDocumentor\Descriptor\Tag\ParamDescriptor":5:{s:15:" * variableName";s:5:"$opts";s:8:" * types";r:59;s:7:" * name";s:5:"param";s:14:" * description";s:0:"";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:6:"return";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:45:"phpDocumentor\Descriptor\Tag\ReturnDescriptor":4:{s:8:" * types";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:51:"phpDocumentor\Descriptor\Type\UnknownTypeDescriptor":1:{s:7:" * name";s:4:"void";}}}s:7:" * name";s:6:"return";s:14:" * description";s:0:"";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}s:18:"handleResponseCode";O:41:"phpDocumentor\Descriptor\MethodDescriptor":17:{s:9:" * parent";r:15;s:11:" * abstract";b:0;s:8:" * final";b:0;s:9:" * static";b:1;s:13:" * visibility";s:6:"public";s:12:" * arguments";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:2:{s:5:"$code";O:43:"phpDocumentor\Descriptor\ArgumentDescriptor":16:{s:9:" * method";r:133;s:8:" * types";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:51:"phpDocumentor\Descriptor\Type\UnknownTypeDescriptor":1:{s:7:" * name";s:5:"mixed";}}}s:10:" * default";N;s:14:" * byReference";b:0;s:13:" * isVariadic";b:0;s:8:" * fqsen";s:0:"";s:7:" * name";s:5:"$code";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:0:"";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:0;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}s:9:"$response";O:43:"phpDocumentor\Descriptor\ArgumentDescriptor":16:{s:9:" * method";r:133;s:8:" * types";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:51:"phpDocumentor\Descriptor\Type\UnknownTypeDescriptor":1:{s:7:" * name";s:5:"mixed";}}}s:10:" * default";s:4:"null";s:14:" * byReference";b:0;s:13:" * isVariadic";b:0;s:8:" * fqsen";s:0:"";s:7:" * name";s:9:"$response";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:0:"";s:14:" * description";s:15:"(default: null)";s:17:" * fileDescriptor";N;s:7:" * line";i:0;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}}}s:8:" * fqsen";s:48:"\mCASH\Utilities\Utilities::handleResponseCode()";s:7:" * name";s:18:"handleResponseCode";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:28:"handleResponseCode function.";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:54;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:4:{s:6:"access";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:38:"phpDocumentor\Descriptor\TagDescriptor":3:{s:7:" * name";s:6:"access";s:14:" * description";s:6:"public";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:6:"static";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:38:"phpDocumentor\Descriptor\TagDescriptor":3:{s:7:" * name";s:6:"static";s:14:" * description";s:0:"";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:5:"param";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:2:{i:0;O:44:"phpDocumentor\Descriptor\Tag\ParamDescriptor":5:{s:15:" * variableName";s:5:"$code";s:8:" * types";r:143;s:7:" * name";s:5:"param";s:14:" * description";s:0:"";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}i:1;O:44:"phpDocumentor\Descriptor\Tag\ParamDescriptor":5:{s:15:" * variableName";s:9:"$response";s:8:" * types";r:165;s:7:" * name";s:5:"param";s:14:" * description";s:15:"(default: null)";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:6:"return";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:45:"phpDocumentor\Descriptor\Tag\ReturnDescriptor":4:{s:8:" * types";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:47:"phpDocumentor\Descriptor\Type\BooleanDescriptor":0:{}}}s:7:" * name";s:6:"return";s:14:" * description";s:37:"Throws Error\Request
Throws Error\Api";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}s:19:"handleErrorResponse";O:41:"phpDocumentor\Descriptor\MethodDescriptor":17:{s:9:" * parent";r:15;s:11:" * abstract";b:0;s:8:" * final";b:0;s:9:" * static";b:1;s:13:" * visibility";s:6:"public";s:12:" * arguments";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{s:9:"$response";O:43:"phpDocumentor\Descriptor\ArgumentDescriptor":16:{s:9:" * method";r:238;s:8:" * types";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:10:" * default";N;s:14:" * byReference";b:0;s:13:" * isVariadic";b:0;s:8:" * fqsen";s:0:"";s:7:" * name";s:9:"$response";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:0:"";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:0;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}}}s:8:" * fqsen";s:49:"\mCASH\Utilities\Utilities::handleErrorResponse()";s:7:" * name";s:19:"handleErrorResponse";s:12:" * namespace";N;s:10:" * package";s:0:"";s:10:" * summary";s:0:"";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:83;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:2:{s:5:"param";a:0:{}s:6:"return";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:2:{i:0;O:40:"phpDocumentor\Descriptor\Validator\Error":4:{s:11:" * severity";s:5:"error";s:7:" * code";s:13:"PPC:ERR-50015";s:7:" * line";i:83;s:10:" * context";a:2:{i:0;s:9:"$response";i:1;s:19:"handleErrorResponse";}}i:1;O:40:"phpDocumentor\Descriptor\Validator\Error":4:{s:11:" * severity";s:5:"error";s:7:" * code";s:13:"PPC:ERR-50008";s:7:" * line";i:83;s:10:" * context";a:2:{s:11:"{{ value }}";s:2:"""";i:0;s:21:"handleErrorResponse()";}}}}s:19:" * inheritedElement";N;}}}s:13:" * usedTraits";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:8:" * fqsen";s:26:"\mCASH\Utilities\Utilities";s:7:" * name";s:9:"Utilities";s:12:" * namespace";s:16:"\mCASH\Utilities";s:10:" * package";s:0:"";s:10:" * summary";s:25:"Abstract Utilities class.";s:14:" * description";s:0:"";s:17:" * fileDescriptor";r:1;s:7:" * line";i:10;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:3:{s:8:"abstract";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:38:"phpDocumentor\Descriptor\TagDescriptor":3:{s:7:" * name";s:8:"abstract";s:14:" * description";s:0:"";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:7:"package";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:38:"phpDocumentor\Descriptor\TagDescriptor":3:{s:7:" * name";s:7:"package";s:14:" * description";s:7:"Default";s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}}s:10:"subpackage";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:19:" * inheritedElement";N;}}}s:13:" * interfaces";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:9:" * traits";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:10:" * markers";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}s:8:" * fqsen";s:0:"";s:7:" * name";s:13:"Utilities.php";s:12:" * namespace";N;s:10:" * package";s:7:"Default";s:10:" * summary";s:0:"";s:14:" * description";s:0:"";s:17:" * fileDescriptor";N;s:7:" * line";i:0;s:7:" * tags";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:2:{s:7:"package";r:315;s:10:"subpackage";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:0:{}}}}s:9:" * errors";O:35:"phpDocumentor\Descriptor\Collection":1:{s:8:" * items";a:1:{i:0;O:40:"phpDocumentor\Descriptor\Validator\Error":4:{s:11:" * severity";s:5:"error";s:7:" * code";s:13:"PPC:ERR-50000";s:7:" * line";i:0;s:10:" * context";a:2:{s:11:"{{ value }}";s:2:"""";i:0;s:0:"";}}}}s:19:" * inheritedElement";N;}