lib/Net/DHCPv6/Option/IATA.pm

filter: Statementstmt 100% 49 / 49 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 14 / 14 Podpod 100% 7 / 7 totaltotal 96.2% 76 / 79 CC 4 SCAR 3.9
CC
4
Cov
98%
new
3.0
from_bytes_inner
2.0
BEGIN
1.0
CRAP 1.5
« lib/Net/DHCPv6/Option/StatusCode.pm ↑ Summary lib/Net/DHCPv6/Option/BootfileUrl.pm »
1 #!/usr/bin/false
2 # ABSTRACT: Identity Association for Temporary Addresses option (code 4)
3 # PODNAME: Net::DHCPv6::Option::IATA
4 package Net::DHCPv6::Option::IATA;
5 15 $Net::DHCPv6::Option::IATA::VERSION = '0.001';
6 15 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use Net::DHCPv6::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Net::DHCPv6::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 11 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod documented
16 11 ▶ croak 'IATA requires iaid' unless defined $args{iaid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"iaid"} 1 10 11
17 10 $args{code} = $OPTION_IA_TA;
18 10 ▶ $args{options} = $args{options} // Net::DHCPv6::OptionList->new;
Condition66%2/3
$args{"options"} // "Net::DHCPv6::OptionList"->new
l!l&&r!l&&!r
910
MC/DC0%0/2
$args{"options"} // "Net::DHCPv6::OptionList"->new
$args{"options"} "Net::DHCPv6::OptionList"->new
Truth table66%2/3
A // B
A= $args{"options"}B= "Net::DHCPv6::OptionList"->new
ABresult
1X1
011
000
19 10 my $data = pack( 'N', $args{iaid} ) . $args{options}->as_bytes;
20 10 $args{data} = $data;
21 10 my $self = $class->SUPER::new( %args );
22 10 $self->{iaid} = $args{iaid};
23 10 $self->{options} = $args{options};
24 10 bless $self, $class;
25 }
26  
27 4 ▶sub iaid { shift->{iaid} }
Subroutine iaid: called CC=1 SCAR=0.0
Pod documented
28 2 ▶sub options { shift->{options} }
Subroutine options: called CC=1 SCAR=0.0
Pod documented
29  
30 sub add_option {
31 1 ▶ my ( $self, $option ) = @_;
Subroutine add_option: called CC=1 SCAR=0.0
Pod documented
32 1 $self->{options}->add_option( $option );
33 }
34  
35 sub get_option {
36 5 ▶ my ( $self, $code ) = @_;
Subroutine get_option: called CC=1 SCAR=0.0
Pod documented
37 5 return $self->{options}->get_option( $code );
38 }
39  
40 sub from_bytes_inner {
41 10 ▶ my ( $class, $code, $data ) = @_;
Subroutine from_bytes_inner: called CC=2 SCAR=6.9
Pod documented
42 10 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated IATA option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $data < 4 1 9 10
43 if CORE::length( $data ) < 4;
44 9 my $iaid = unpack( 'N', substr( $data, 0, 4 ) );
45 9 my $opt_data = substr( $data, 4 );
46 9 my $opts = Net::DHCPv6::OptionList->from_bytes( $opt_data );
47 9 return $class->new( iaid => $iaid, options => $opts );
48 }
49  
50 sub as_bytes {
51 1 ▶ my $self = shift;
Subroutine as_bytes: called CC=1 SCAR=0.0
Pod documented
52 1 my $data = pack( 'N', $self->{iaid} ) . $self->{options}->as_bytes;
53 1 return pack( 'nn', $self->{code}, CORE::length( $data ) ) . $data;
54 }
55  
56 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_IA_TA} = __PACKAGE__;
57  
58 15 1;
59  
60 __END__
« lib/Net/DHCPv6/Option/StatusCode.pm ↑ Summary lib/Net/DHCPv6/Option/BootfileUrl.pm »