MangoPay/ApiUsers.php
private function GetUserResponse($response)
    {
        if (isset($response->PersonType)) {
            switch ($response->PersonType) {
                case PersonType::Natural:
                    return $this->CastResponseToEntity($response, '\MangoPay\UserNatural');
                case PersonType::Legal:
                    return $this->CastResponseToEntity($response, '\MangoPay\UserLegal');
                default:
                    throw new Libraries\Exception('Unexpected response. Wrong PersonType value');
            }
        } else {
            throw new Libraries\Exception('Unexpected response. Missing PersonType property');
        }
    }
private function GetUserResponse($response)
    {
        if (isset($response->PersonType)) {
            switch ($response->PersonType) {
                case PersonType::Natural:
                    return $this->CastResponseToEntity($response, '\MangoPay\UserNatural');
                case PersonType::Legal:
                    return $this->CastResponseToEntity($response, '\MangoPay\UserLegal');
                default:
                    throw new Libraries\Exception('Unexpected response. Wrong PersonType value');
            }
        } else {
            throw new Libraries\Exception('Unexpected response. Missing PersonType property');
        }
    }
private function GetUserResponse ( $ response ) { if ( isset ( $ response -> PersonType ) ) { switch ( $ response -> PersonType ) { case PersonType :: Natural : return $ this -> CastResponseToEntity ( $ response , '\MangoPay\UserNatural' ) ; case PersonType :: Legal : return $ this -> CastResponseToEntity ( $ response , '\MangoPay\UserLegal' ) ; default : throw new Libraries \ Exception ( 'Unexpected response. Wrong PersonType value' ) ; } } else { throw new Libraries \ Exception ( 'Unexpected response. Missing PersonType property' ) ; } }
Get correct user object
@param object $response Response from API
@return UserLegal|UserNatural User object returned from API
@throws \MangoPay\Libraries\Exception If occur unexpected response from API
Get correct user object