blib/lib/Dispatch/Class.pm

filter: Statementstmt 100% 28 / 28 Branchbran 91.6% 11 / 12 Conditioncond 70.0% 7 / 10 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 89.2% 58 / 65 CC 11 SCAR 18.2
CC
11
Cov
92%
__ANON__
10.1
__ANON__
2.1
dispatch
1.0
CRAP 6.2
↑ Summary
1 package Dispatch::Class;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.04';
7  
8 2 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use parent 'Exporter::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 our @EXPORT_OK = qw(
12 class_case
13 dispatch
14 );
15  
16 2 ▶sub class_case {
Subroutine class_case: called CC=1 SCAR=0.0
Pod documented
17 2 my @prototable = @_;
18 16 ▶ sub {
Subroutine __ANON__: called CC=10 SCAR=23.1
19 16 my ($x) = @_;
20 16 my $blessed = blessed $x;
21 16 my $ref = ref $x;
22 16 my $DOES;
23 16 my @table = @prototable;
24 16 ▶ while (my ($key, $value) = splice @table, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@table, 0, 2)) 62 2 64
25 62 ▶ return $value if
Branch: 5 branches
BranchTrueFalseTotal
if !defined($key) ? !defined($x) : ($key eq "*" ? 1 : ($key eq ":str" ? !$ref : ($key eq $ref ? 1 : $blessed && ($DOES ||= $x->can("DOES") || "isa", $x->$DOES($key))))) 14 48 62
!defined($key) ? : 0 62 62
$key eq '*' ? : 1 61 62
$key eq ':str' ? : 4 57 61
$key eq $ref ? : 7 50 57
Condition75%6/8
$blessed and $DOES ||= $x->can("DOES") || "isa", $x->$DOES($key)
!ll&&!rl&&r
24224
$DOES ||= $x->can("DOES") || "isa"
l!l&&r!l&&!r
1790
$x->can('DOES') || 'isa'
l!l
90
MC/DC100%2/2
$blessed and $DOES ||= $x->can("DOES") || "isa", $x->$DOES($key)
$blessed $DOES ||= $x->can("DOES") || "isa", $x->$DOES($key)
MC/DC0%0/2
$DOES ||= $x->can("DOES") || "isa"
$DOES $x->can('DOES')
Truth table100%3/3
A and B
A= $blessedB= $DOES ||= $x->can("DOES") || "isa", $x->$DOES($key)
ABresult
0X0
100
111
Truth table66%2/3
A ||= B
A= $DOESB= $x->can('DOES')
ABresult
1X1
011
000
26 !defined $key ? !defined $x :
27 $key eq '*' ? 1 :
28 $key eq ':str' ? !$ref :
29 $key eq $ref ? 1 :
30 $blessed && ($DOES ||= $x->can('DOES') || 'isa', $x->$DOES($key))
31 ;
32 }
33 ()
34 2 }
35 2 }
36  
37 1 ▶sub dispatch {
Subroutine dispatch: called CC=1 SCAR=0.1
Pod documented
38 1 my $chk = &class_case;
39 12 ▶ sub { ($chk->($_[0]) || return)->($_[0]) }
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
&$chk($_[0]) || (return)
l!l
120
MC/DC0%0/1
&$chk($_[0]) || (return)
&$chk($_[0])
Truth table50%1/2
A
A= &$chk($_[0])
Aresult
11
00
40 1 }
41  
42 2 'ok'
43  
44 __END__
↑ Summary