blib/lib/Net/IP/Checker.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 91.6% 44 / 48 SCAR 18.0
CC
6
Cov
92%
ip_get_version
4.3
ip_is_ipv4
2.0
ip_is_ipv6
2.0
CRAP 6.0
↑ Summary
1 #ABSTRACT: IPv4/IPv6 addresses validator
2  
3  
4 package Net::IP::Checker;
5 1 $Net::IP::Checker::VERSION = '0.02';
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Regexp::IPv6 qw($IPv6_re);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Regexp::IPv4 qw($IPv4_re);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 require Exporter;
12  
13 1 our @ISA = qw(Exporter);
14 1 our @EXPORT_OK = qw(ip_get_version ip_is_ipv4 ip_is_ipv6);
15 1 our %EXPORT_TAGS = ( 'ALL' => [@EXPORT_OK] );
16  
17  
18 sub ip_get_version {
19 2 ▶ my $ip = shift;
Subroutine ip_get_version: called CC=4 SCAR=14.6
Pod documented
20 2 ▶ $ip !~ /:/ and ip_is_ipv4($ip) and return '4';
Branch: 1 branch
BranchTrueFalseTotal
not $ip =~ /:/ and ip_is_ipv4($ip) and return 4 1 1 2
Condition66%2/3
not $ip =~ /:/ and ip_is_ipv4($ip)
!ll&&!rl&&r
101
MC/DC50%1/2
not $ip =~ /:/ and ip_is_ipv4($ip)
not $ip =~ /:/ ip_is_ipv4($ip)
Truth table66%2/3
not(A) and B
A= not $ip =~ /:/B= ip_is_ipv4($ip)
ABresult
0X0
100
111
21 1 ▶ ip_is_ipv6($ip) and return '6';
Branch: 1 branch
BranchTrueFalseTotal
ip_is_ipv6($ip) and return 6 1 0 1
22 0 return;
23 }
24  
25  
26 sub ip_is_ipv4 {
27 16 ▶ my $ip = shift;
Subroutine ip_is_ipv4: called CC=2 SCAR=6.9
Pod documented
28 16 ▶ return $ip =~ /^$IPv4_re$/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$ip =~ /^$Net::IP::Checker::IPv4_re$/ ? : 4 12 16
29 }
30  
31  
32 sub ip_is_ipv6 {
33 24 ▶ my $ip = shift;
Subroutine ip_is_ipv6: called CC=2 SCAR=6.9
Pod documented
34 24 ▶ return $ip =~ /^$IPv6_re$/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$ip =~ /^$Net::IP::Checker::IPv6_re$/ ? : 4 20 24
35 }
36  
37 __END__
↑ Summary