| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package IP::Geolocation::MMDB; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 1 |  |  | 1 |  | 181314 | use 5.016; | 
|  | 1 |  |  |  |  | 10 |  | 
| 6 | 1 |  |  | 1 |  | 16 | use warnings; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 41 |  | 
| 7 | 1 |  |  | 1 |  | 6 | use utf8; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our $VERSION = 1.010; | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 1 |  |  | 1 |  | 498 | use IP::Geolocation::MMDB::Metadata; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 33 |  | 
| 12 | 1 |  |  | 1 |  | 1144 | use Math::BigInt 1.999806; | 
|  | 1 |  |  |  |  | 26103 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | require XSLoader; | 
| 15 |  |  |  |  |  |  | XSLoader::load(__PACKAGE__, $VERSION); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub getcc { | 
| 18 | 2 |  |  | 2 | 1 | 2211 | my ($self, $ip_address) = @_; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 2 |  |  |  |  | 4 | my $country_code; | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 2 |  |  |  |  | 85 | my $data = $self->record_for_address($ip_address); | 
| 23 | 2 | 50 |  |  |  | 1278 | if (ref $data eq 'HASH') { | 
| 24 | 2 | 50 |  |  |  | 6 | if (exists $data->{country}) { | 
| 25 | 2 |  |  |  |  | 12 | my $country = $data->{country}; | 
| 26 | 2 | 50 |  |  |  | 6 | if (exists $country->{iso_code}) { | 
| 27 | 2 |  |  |  |  | 5 | $country_code = $country->{iso_code}; | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 2 |  |  |  |  | 28 | return $country_code; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | sub metadata { | 
| 36 | 1 |  |  | 1 | 1 | 8048 | my ($self) = @_; | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 1 |  |  |  |  | 3 | return IP::Geolocation::MMDB::Metadata->new(%{$self->_metadata}); | 
|  | 1 |  |  |  |  | 44 |  | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub _to_bigint { | 
| 44 | 14 |  |  | 14 |  | 13537 | my ($self, $bytes) = @_; | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 14 |  |  |  |  | 47 | return Math::BigInt->from_bytes($bytes); | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | 1; | 
| 50 |  |  |  |  |  |  | __END__ |