lib/Net/DHCPv6/Option/ElapsedTime.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 100% 54 / 54 CC 3 SCAR 2.9
CC
3
Cov
100%
new
2.0
from_bytes_inner
2.0
BEGIN
1.0
CRAP 1.3
« lib/Net/DHCPv6/Option/ClientArchType.pm ↑ Summary lib/Net/DHCPv6/Option/Preference.pm »
1 #!/usr/bin/false
2 # ABSTRACT: Elapsed Time option (code 8) — 16-bit centiseconds
3 # PODNAME: Net::DHCPv6::Option::ElapsedTime
4 package Net::DHCPv6::Option::ElapsedTime;
5 15 $Net::DHCPv6::Option::ElapsedTime::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::X::BadOption;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new {
14 28 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
15 28 ▶ croak 'ElapsedTime requires centiseconds' unless defined $args{centiseconds};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"centiseconds"} 1 27 28
16 27 $args{code} = $OPTION_ELAPSED_TIME;
17 27 $args{data} = pack( 'n', $args{centiseconds} );
18 27 my $self = $class->SUPER::new( %args );
19 27 $self->{centiseconds} = $args{centiseconds};
20 27 bless $self, $class;
21 }
22  
23 11 ▶sub centiseconds { shift->{centiseconds} }
Subroutine centiseconds: called CC=1 SCAR=0.0
Pod documented
24  
25 sub from_bytes_inner {
26 27 ▶ my ( $class, $code, $data ) = @_;
Subroutine from_bytes_inner: called CC=2 SCAR=6.9
Pod documented
27 27 ▶ Net::DHCPv6::X::BadOption->throw( message => 'ElapsedTime option must be exactly 2 bytes' )
Branch: 1 branch
BranchTrueFalseTotal
if length $data != 2 1 26 27
28 if CORE::length( $data ) != 2;
29 26 my $cs = unpack( 'n', $data );
30 26 return $class->new( centiseconds => $cs );
31 }
32  
33 sub as_bytes {
34 5 ▶ my $self = shift;
Subroutine as_bytes: called CC=1 SCAR=0.0
Pod documented
35 5 my $data = pack( 'n', $self->{centiseconds} );
36 5 return pack( 'nn', $self->{code}, CORE::length( $data ) ) . $data;
37 }
38  
39 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_ELAPSED_TIME} = __PACKAGE__;
40  
41 15 1;
42  
43 __END__
« lib/Net/DHCPv6/Option/ClientArchType.pm ↑ Summary lib/Net/DHCPv6/Option/Preference.pm »