blib/lib/ASNMTAP/PseudoHash.pm

filter: Statementstmt 68.1% 47 / 69 Branchbran 25.0% 4 / 16 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 60.0% 15 / 25 Podpod n/a totaltotal 56.6% 68 / 120 CC 10 SCAR 12.9
CC
10
Cov
58%
FETCH
8.9
STORE
8.9
INIT
2.0
CRAP 3.6
« blib/lib/ASNMTAP/Asnmtap.pm ↑ Summary plugins/templates/check_template-mail-fingerprint-xml.pl »
1 # ----------------------------------------------------------------------------------------------------------
2 # © Copyright 2003-2011 by Alex Peeters [alex.peeters@citap.be]
3 # ----------------------------------------------------------------------------------------------------------
4 # 2011/mm/dd, v3.002.003, package ASNMTAP::PseudoHash
5 # ----------------------------------------------------------------------------------------------------------
6  
7 # package ASNMTAP::PseudoHash;
8  
9 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10  
11 107 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 107 ▶use warnings; # Must be used in test mode only. This reduces a little process speed
Subroutine BEGIN: called CC=1 SCAR=0.0
13 #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
14  
15 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16  
17 107 ▶use vars qw/$FixedKeys $Obj $Proxy/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
20 # Constants = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
21 # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
22  
23 107 ▶use constant NO_SUCH_FIELD => 'No such pseudohash field "%s"';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 107 ▶use constant NO_SUCH_INDEX => 'Bad index while coercing array into hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # SET ASNMTAP::PseudoHash VARIABLES - - - - - - - - - - - - - - - - - - -
27  
28 107 our $FixedKeys = 1;
29  
30 # Constructor & initialisation - - - - - - - - - - - - - - - - - - - - -
31  
32 107 ▶unless ( $] < 5.010000 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($] < "5.01") 107 0 107
33 eval {
34 107 ▶ use overload (
Subroutine BEGIN: called CC=1 SCAR=0.4
35 11968 ▶ '%{}' => sub { $$Obj = $_[0]; return $Proxy },
Subroutine __ANON__: called CC=1 SCAR=0.0
36 130 ▶ '""' => sub { overload::AddrRef($_[0]) },
Subroutine __ANON__: called CC=1 SCAR=0.0
37 107 ▶ '0+' => sub { no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: not called CC=1 SCAR=0.6
38 0 my $str = overload::AddrRef($_[0]);
39 0 hex(substr($str, index($str, '(') + 1, -1));
40 },
41 0 ▶ 'bool' => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 ▶ 'cmp' => sub { "$_[0]" cmp "$_[1]" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
43 0 ▶ '<=>' => sub { "$_[0]" cmp "$_[1]" }, # for completeness' sake
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 107 'fallback' => 1,
45 107 );
46  
47 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48  
49 107 ▶ INIT {
Subroutine INIT: called CC=2 SCAR=7.1
50 107 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 107 my $class = __PACKAGE__;
53 107 tie %{$Proxy}, $class;
54
55 0 ▶ *{'fields::phash'} = sub { $class->new(@_); } unless defined $_[0];
Subroutine __ANON__: not called CC=1 SCAR=0.6
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 107 0 107
56 }
57  
58 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59  
60 10458 ▶ sub FETCH {
Subroutine FETCH: called CC=5 SCAR=21.9
61 10458 my ($self, $key) = @_;
62  
63 10458 $self = $$$self;
64 10458 ▶ my $index = ( ( defined $self->[0]{$key} and $self->[0]{$key} >= 1 ) ? $self->[0]{$key} : ( defined $self->[0]{$key} ? _cluck(NO_SUCH_INDEX) : ( $FixedKeys ? _cluck(NO_SUCH_FIELD, $key) : @$self ) ) );
Branch: 3 branches
BranchTrueFalseTotal
defined $self->[0]{$key} && $self->[0]{$key} >= 1 ? : 10458 0 10458
defined $self->[0]{$key} ? : 0 0 0
$ASNMTAP::Asnmtap::FixedKeys ? : 0 0 0
Condition33%1/3
defined $self->[0]{$key} and $self->[0]{$key} >= 1
!ll&&!rl&&r
0010458
MC/DC0%0/2
defined $self->[0]{$key} and $self->[0]{$key} >= 1
defined $self->[0]{$key} $self->[0]{$key} >= 1
Truth table33%1/3
A and B
A= defined $self->[0]{$key}B= $self->[0]{$key} >= 1
ABresult
0X0
100
111
65 10458 return $self->[ $index ];
66 }
67  
68 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69  
70 1376 ▶ sub STORE {
Subroutine STORE: called CC=5 SCAR=21.9
71 1376 my ($self, $key, $value) = @_;
72  
73 1376 $self = $$$self;
74 1376 ▶ my $index = ( ( defined $self->[0]{$key} and $self->[0]{$key} >= 1 ) ? $self->[0]{$key} : ( defined $self->[0]{$key} ? _cluck(NO_SUCH_INDEX) : ( $FixedKeys ? _cluck(NO_SUCH_FIELD, $key) : @$self ) ) );
Branch: 3 branches
BranchTrueFalseTotal
defined $self->[0]{$key} && $self->[0]{$key} >= 1 ? : 1376 0 1376
defined $self->[0]{$key} ? : 0 0 0
$ASNMTAP::Asnmtap::FixedKeys ? : 0 0 0
Condition33%1/3
defined $self->[0]{$key} and $self->[0]{$key} >= 1
!ll&&!rl&&r
001376
MC/DC0%0/2
defined $self->[0]{$key} and $self->[0]{$key} >= 1
defined $self->[0]{$key} $self->[0]{$key} >= 1
Truth table33%1/3
A and B
A= defined $self->[0]{$key}B= $self->[0]{$key} >= 1
ABresult
0X0
100
111
75 1376 return $self->[ $index ] = $value;
76 }
77  
78 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79  
80 107 ▶ sub TIEHASH {
Subroutine TIEHASH: called CC=1 SCAR=0.0
81 107 bless \$Obj => shift;
82 }
83  
84 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85  
86 0 ▶ sub FIRSTKEY {
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
87 0 scalar keys %{$${$_[0]}->[0]};
88 0 each %{$${$_[0]}->[0]};
89 }
90  
91 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
92  
93 0 ▶ sub NEXTKEY {
Subroutine NEXTKEY: not called CC=1 SCAR=6.9
94 0 each %{$${$_[0]}->[0]};
95 }
96  
97 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98  
99 150 ▶ sub EXISTS {
Subroutine EXISTS: called CC=1 SCAR=0.0
100 150 exists $${$_[0]}->[0]{$_[1]};
101 }
102  
103 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104  
105 0 ▶ sub DELETE {
Subroutine DELETE: not called CC=1 SCAR=6.9
106 0 delete $${$_[0]}->[0]{$_[1]};
107 }
108  
109 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110  
111 0 ▶ sub CLEAR {
Subroutine CLEAR: not called CC=1 SCAR=6.9
112 0 @{$${$_[0]}} = ();
113 }
114  
115 # Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - -
116  
117 0 ▶ sub _cluck {
Subroutine _cluck: not called CC=1 SCAR=6.9
118 0 require Carp;
119 0 Carp::cluck(sprintf(shift, @_));
120 }
121  
122 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
123 }
124 107 }
125  
126 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
127  
128 107 1;
129  
130 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131  
132 __END__
« blib/lib/ASNMTAP/Asnmtap.pm ↑ Summary plugins/templates/check_template-mail-fingerprint-xml.pl »