lib/Net/DHCPv6/Option/VendorOpts.pm

filter: Statementstmt 95.5% 43 / 45 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 3 / 3 totaltotal 88.5% 62 / 70 CC 5 SCAR 7.1
CC
5
Cov
89%
new
4.3
from_bytes_inner
2.0
BEGIN
1.0
CRAP 2.0
« lib/Net/DHCPv6/Option/IAPD.pm ↑ Summary blib/lib/Net/DHCPv6/Constants.pm »
1 #!/bin/false
2 # ABSTRACT: Vendor-specific Information option (code 17) -- enterprise + sub-options
3 # PODNAME: Net::DHCPv6::Option::VendorOpts
4 15 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Net::DHCPv6::Option::VendorOpts;
7 15 $Net::DHCPv6::Option::VendorOpts::VERSION = '0.002';
8 15 ▶use Net::DHCPv6::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Net::DHCPv6::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 ▶use Ref::Util qw( is_plain_arrayref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 15 my $EMPTY = q();
16 15 my $ENT_NUM_LEN = 4; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
17  
18 sub new {
19 3 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=4 SCAR=14.7
Pod documented
20 3 ▶ croak 'VendorOpts requires enterprise_number' unless defined $args{enterprise_number};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"enterprise_number"} 1 2 3
21 2 $args{code} = $OPTION_VENDOR_OPTS;
22 2 ▶ my $sub_data = $args{sub_options} // $EMPTY;
Condition33%1/3
$args{"sub_options"} // $EMPTY
l!l&&r!l&&!r
200
MC/DC0%0/2
$args{"sub_options"} // $EMPTY
$args{"sub_options"} $EMPTY
Truth table33%1/3
A // B
A= $args{"sub_options"}B= $EMPTY
ABresult
1X1
011
000
23 2 ▶ $sub_data = join( $EMPTY, map { $_->as_bytes } @{$sub_data} ) if is_plain_arrayref( $sub_data );
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_plain_arrayref($sub_data) 0 2 2
24 2 $args{data} = pack( 'N', $args{enterprise_number} ) . $sub_data;
25 2 my $self = $class->SUPER::new( %args );
26 2 $self->{enterprise_number} = $args{enterprise_number};
27 2 return bless $self, $class;
28 }
29  
30 2 ▶sub enterprise_number { return shift->{enterprise_number} }
Subroutine enterprise_number: called CC=1 SCAR=0.0
Pod documented
31  
32 sub from_bytes_inner {
33 1 ▶ my ( $class, $code, $payload ) = @_;
Subroutine from_bytes_inner: called CC=2 SCAR=7.0
Pod documented
34 1 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated VendorOpts option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $payload < $ENT_NUM_LEN 0 1 1
35 if CORE::length( $payload ) < $ENT_NUM_LEN;
36 1 my $en = unpack( 'N', substr( $payload, 0, $ENT_NUM_LEN ) );
37 1 return $class->new( enterprise_number => $en, sub_options => substr( $payload, $ENT_NUM_LEN ) );
38 }
39  
40 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_VENDOR_OPTS} = __PACKAGE__;
41 15 1;
42  
43 __END__
« lib/Net/DHCPv6/Option/IAPD.pm ↑ Summary blib/lib/Net/DHCPv6/Constants.pm »