Radius/Dictionary.pm

filter: Statementstmt 90.5% 48 / 53 Branchbran 50.0% 10 / 20 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 93.7% 15 / 16 Podpod 10.0% 1 / 10 totaltotal 71.0% 76 / 107 CC 14 SCAR 10.0
CC
14
Cov
77%
vendor_name
6.0
_combine_existing_dicts
4.1
from_multiple_files
3.7
CRAP 2.7
« Radius/Decode.pm ↑ Summary Radius/Util.pm »
1 package Data::Radius::Dictionary;
2  
3 4 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use base qw(Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 __PACKAGE__->mk_accessors(qw(attr_id attr_name const_name const_value vnd_name vnd_id));
9  
10 4 ▶use Data::Radius::DictionaryParser ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub new {
13 6 ▶ my ($class, %h) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
14 6 return bless({ %h }, $class);
15 }
16  
17 sub _combine_existing_dicts {
18 1 ▶ my ($class, @dict_paths) = @_;
Subroutine _combine_existing_dicts: called CC=4 SCAR=14.1
19  
20 1 my @existing_paths;
21 1 foreach my $dict_path ( @dict_paths ) {
22 2 ▶ if ( -r $dict_path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-r $dict_path) 2 0 2
23 2 push @existing_paths => $dict_path;
24 }
25 }
26  
27 1 ▶ return @existing_paths ? [ map { '$INCLUDE ' . $_ } @existing_paths ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@existing_paths ? : 1 0 1
28 }
29  
30 sub from_multiple_files {
31 1 ▶ my ($class, @files) = @_;
Subroutine from_multiple_files: called CC=3 SCAR=13.0
Pod undocumented
32  
33 1 my $arref_of_includes = $class->_combine_existing_dicts(@files);
34 1 ▶ if ( !$arref_of_includes || !@{$arref_of_includes} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arref_of_includes and @{$arref_of_includes;}) 0 1 1
Condition33%1/3
$arref_of_includes and @{$arref_of_includes;}
!ll&&!rl&&r
001
MC/DC0%0/2
$arref_of_includes and @{$arref_of_includes;}
$arref_of_includes @{$arref_of_includes;}
Truth table33%1/3
A and B
A= $arref_of_includesB= @{$arref_of_includes;}
ABresult
0X0
100
111
35 0 warn 'No usable RADIUS dictionaries was provided';
36 0 return undef;
37 }
38  
39 1 return Data::Radius::DictionaryParser->new()
40 ->parse_str_array($arref_of_includes);
41 }
42  
43 sub load_file {
44 5 ▶ my ($class, $file) = @_;
Subroutine load_file: called CC=1 SCAR=0.0
Pod undocumented
45 5 return Data::Radius::DictionaryParser->new()->parse_file($file);
46 }
47  
48 sub attribute {
49 21 ▶ my ($self, $attr_name) = @_;
Subroutine attribute: called CC=2 SCAR=7.1
Pod undocumented
50 21 ▶ return undef if (! $attr_name);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr_name 0 21 21
51 # hash-ref with {id, type, vendor, parent}
52 21 return $self->attr_name()->{ $attr_name };
53 }
54  
55 sub attribute_name {
56 3 ▶ my ($self, $vendor_name, $id) = @_;
Subroutine attribute_name: called CC=2 SCAR=7.2
Pod undocumented
57 3 ▶ return $self->attr_id()->{ $vendor_name // '' }{$id};
Condition50%1/2
$vendor_name // ""
l!l
03
MC/DC0%0/1
$vendor_name // ""
$vendor_name
Truth table50%1/2
A
A= $vendor_name
Aresult
11
00
58 }
59  
60 sub tlv_attribute_name {
61 3 ▶ my ($self, $parent, $id) = @_;
Subroutine tlv_attribute_name: called CC=1 SCAR=0.0
Pod undocumented
62 3 return $parent->{tlv_attr_id}{ $id };
63 }
64  
65 sub vendor_id {
66 5 ▶ my ($self, $vendor_name) = @_;
Subroutine vendor_id: called CC=2 SCAR=6.9
Pod undocumented
67 5 ▶ return undef if (! $vendor_name);
Branch: 1 branch
BranchTrueFalseTotal
unless $vendor_name 4 1 5
68 1 return $self->vnd_name()->{ $vendor_name };
69 }
70  
71 sub vendor_name {
72 0 ▶ my ($self, $vendor_id) = @_;
Subroutine vendor_name: not called CC=2 SCAR=17.9
Pod undocumented
73 0 ▶ return undef if (! $vendor_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $vendor_id 0 0 0
74 0 return $self->vnd_id()->{ $vendor_id };
75 }
76  
77 # VALUE Service-Type Login-User 1
78 # Convert 'Login-User' to 1
79 sub value {
80 1 ▶ my ($self, $attr_name, $const_name) = @_;
Subroutine value: called CC=3 SCAR=11.7
Pod undocumented
81 1 ▶ return undef if (! defined $const_name);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $const_name 0 1 1
82 1 ▶ return $self->const_value()->{ $attr_name } ? $self->const_value()->{ $attr_name }{ $const_name } : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->const_value->{$attr_name} ? : 1 0 1
83 }
84  
85 sub constant {
86 1 ▶ my ($self, $attr_name, $const_value) = @_;
Subroutine constant: called CC=3 SCAR=11.7
Pod undocumented
87 1 ▶ return undef if (! defined $const_value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $const_value 0 1 1
88 1 ▶ return $self->const_name()->{ $attr_name } ? $self->const_name()->{ $attr_name }{ $const_value } : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->const_name->{$attr_name} ? : 1 0 1
89 }
90  
91 4 1;
92  
93 __END__
« Radius/Decode.pm ↑ Summary Radius/Util.pm »