File Coverage

blib/lib/Geo/Location/IP/Record/Traits.pm
Criterion Covered Total %
statement 65 65 100.0
branch n/a
condition 24 42 57.1
subroutine 28 28 100.0
pod 21 21 100.0
total 138 156 88.4


line stmt bran cond sub pod time code
1             package Geo::Location::IP::Record::Traits;
2              
3             # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
4              
5 14     14   1027 use 5.026;
  14         65  
6 14     14   72 use warnings;
  14         21  
  14         666  
7 14     14   66 use utf8;
  14         22  
  14         73  
8              
9 14     14   411 use Object::Pad;
  14         22  
  14         74  
10              
11             class Geo::Location::IP::Record::Traits;
12              
13             our $VERSION = 0.005;
14              
15 14     14   5389 use Geo::Location::IP::Address;
  14         29  
  14         18133  
16              
17 4     4   2407 apply Geo::Location::IP::Role::HasIPAddress;
  4         13  
  4         9510  
18              
19             field $autonomous_system_number :param :reader = undef;
20 2     2 1 35 field $autonomous_system_organization :param :reader = undef;
  2         16  
21 2     2 1 12 field $connection_type :param :reader = undef;
  2         13  
22 1     1 1 6 field $domain :param :reader = undef;
  1         7  
23 4     4 1 28 field $is_anonymous :param :reader = 0;
  4     1 1 23  
  1         6  
24 1     1 1 7 field $is_anonymous_proxy :param :reader = 0;
  1         5  
25 1     1 1 7 field $is_anonymous_vpn :param :reader = 0;
  1         6  
26 1     1 1 6 field $is_anycast :param :reader = 0;
  1         6  
27 1     1 1 7 field $is_hosting_provider :param :reader = 0;
  1         7  
28 1     1 1 6 field $is_legitimate_proxy :param :reader = 0;
  1         6  
29 1     1 1 13 field $is_public_proxy :param :reader = 0;
  1         5  
30 1     1 1 7 field $is_residential_proxy :param :reader = 0;
  1         6  
31 1     1 1 6 field $is_satellite_provider :param :reader = 0;
  1         5  
32 1     1 1 6 field $is_tor_exit_node :param :reader = 0;
  1         5  
33 1         5 field $isp :param :reader = undef;
34 1     1 1 6 field $mobile_country_code :param :reader = undef;
  1         7  
35 1     1 1 6 field $mobile_network_code :param :reader = undef;
  1         7  
36 1     1 1 6 field $organization :param :reader = undef;
  1         7  
37 1     1 1 6 field $static_ip_score :param :reader = undef;
  1         8  
38 1     1 1 7 field $user_count :param :reader = undef;
  1         7  
39 1     1 1 6 field $user_type :param :reader = undef;
  1         8  
40              
41 9     9 1 26 sub _from_hash ($class, $hash_ref, $ip_address) {
  9     1   23  
  9         22  
  9         19  
  9         19  
  1         5  
  1         9  
42             return $class->new(
43             autonomous_system_number => $hash_ref->{autonomous_system_number}
44             // undef,
45             autonomous_system_organization =>
46             $hash_ref->{autonomous_system_organization} // undef,
47             connection_type => $hash_ref->{connection_type} // undef,
48             domain => $hash_ref->{domain} // undef,
49             ip_address =>
50             Geo::Location::IP::Address->_from_hash($hash_ref, $ip_address),
51             is_anonymous => $hash_ref->{is_anonymous} // 0,
52             is_anonymous_proxy => $hash_ref->{is_anonymous_proxy} // 0,
53             is_anonymous_vpn => $hash_ref->{is_anonymous_vpn} // 0,
54             is_anycast => $hash_ref->{is_anycast} // 0,
55             is_hosting_provider => $hash_ref->{is_hosting_provider} // 0,
56             is_legitimate_proxy => $hash_ref->{is_legitimate_proxy} // 0,
57             is_public_proxy => $hash_ref->{is_public_proxy} // 0,
58             is_residential_proxy => $hash_ref->{is_residential_proxy} // 0,
59             is_satellite_provider => $hash_ref->{is_satellite_provider} // 0,
60             is_tor_exit_node => $hash_ref->{is_tor_exit_node} // 0,
61             isp => $hash_ref->{isp} // undef,
62             mobile_country_code => $hash_ref->{mobile_country_code} // undef,
63             mobile_network_code => $hash_ref->{mobile_network_code} // undef,
64             organization => $hash_ref->{organization} // undef,
65             static_ip_score => $hash_ref->{static_ip_score} // undef,
66             user_count => $hash_ref->{user_count} // undef,
67             user_type => $hash_ref->{user_type} // undef,
68 9   100     265 );
      100        
      50        
      100        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
69             }
70              
71             1;
72             __END__