lib/Util/Util.php
public static function convertToPayjpObject($resp, $opts)
    {
        $types = array(
            'account' => 'Payjp\\Account',
            'card' => 'Payjp\\Card',
            'charge' => 'Payjp\\Charge',
            'customer' => 'Payjp\\Customer',
            'list' => 'Payjp\\Collection',
            'event' => 'Payjp\\Event',
            'token' => 'Payjp\\Token',
            'transfer' => 'Payjp\\Transfer',
            'plan' => 'Payjp\\Plan',
            'subscription' => 'Payjp\\Subscription',
        );
        if (self::isList($resp)) {
            $mapped = array();
            foreach ($resp as $i) {
                array_push($mapped, self::convertToPayjpObject($i, $opts));
            }
            return $mapped;
        } elseif (is_array($resp)) {
            if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
                $class = $types[$resp['object']];
            } else {
                $class = 'Payjp\\PayjpObject';
            }
            return $class::constructFrom($resp, $opts);
        } else {
            return $resp;
        }
    }
public static function convertToPayjpObject($resp, $opts)
    {
        $types = array(
            'account' => 'Payjp\\Account',
            'card' => 'Payjp\\Card',
            'charge' => 'Payjp\\Charge',
            'customer' => 'Payjp\\Customer',
            'list' => 'Payjp\\Collection',
            'event' => 'Payjp\\Event',
            'token' => 'Payjp\\Token',
            'transfer' => 'Payjp\\Transfer',
            'plan' => 'Payjp\\Plan',
            'subscription' => 'Payjp\\Subscription',
        );
        if (self::isList($resp)) {
            $mapped = array();
            foreach ($resp as $i) {
                array_push($mapped, self::convertToPayjpObject($i, $opts));
            }
            return $mapped;
        } elseif (is_array($resp)) {
            if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
                $class = $types[$resp['object']];
            } else {
                $class = 'Payjp\\PayjpObject';
            }
            return $class::constructFrom($resp, $opts);
        } else {
            return $resp;
        }
    }
public static function convertToPayjpObject ( $ resp , $ opts ) { $ types = array ( 'account' => 'Payjp\\Account' , 'card' => 'Payjp\\Card' , 'charge' => 'Payjp\\Charge' , 'customer' => 'Payjp\\Customer' , 'list' => 'Payjp\\Collection' , 'event' => 'Payjp\\Event' , 'token' => 'Payjp\\Token' , 'transfer' => 'Payjp\\Transfer' , 'plan' => 'Payjp\\Plan' , 'subscription' => 'Payjp\\Subscription' , ) ; if ( self :: isList ( $ resp ) ) { $ mapped = array ( ) ; foreach ( $ resp as $ i ) { array_push ( $ mapped , self :: convertToPayjpObject ( $ i , $ opts ) ) ; } return $ mapped ; } elseif ( is_array ( $ resp ) ) { if ( isset ( $ resp [ 'object' ] ) && is_string ( $ resp [ 'object' ] ) && isset ( $ types [ $ resp [ 'object' ] ] ) ) { $ class = $ types [ $ resp [ 'object' ] ] ; } else { $ class = 'Payjp\\PayjpObject' ; } return $ class :: constructFrom ( $ resp , $ opts ) ; } else { return $ resp ; } }
Converts a response from the Payjp API to the corresponding PHP object.

@param array $resp The response from the Payjp API.
@param array $opts
@return Object|array
Converts a response from the Payjp API to the corresponding PHP object .