BestChoice/Ranker.pm

filter: Statementstmt 80.0% 24 / 30 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 4 totaltotal 64.1% 34 / 53 CC 5 SCAR 13.1
CC
5
Cov
72%
parse
7.1
rank
2.0
rank
2.0
CRAP 3.7
« BestChoice.pm ↑ Summary BestChoice/Matcher.pm »
1 package Algorithm::BestChoice::Ranker;
2  
3 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use Scalar::Util qw/looks_like_number/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶sub parse {
Subroutine parse: called CC=5 SCAR=19.6
Pod undocumented
8 10 my $class = shift;
9 10 my $ranker = shift;
10  
11 10 ▶ return Algorithm::BestChoice::Ranker::Value->new( value => 0 ) unless defined $ranker;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ranker 2 8 10
12  
13 8 ▶ if (ref $ranker eq '' && looks_like_number $ranker) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $ranker eq '' and &looks_like_number($ranker)) { } 8 0 8
elsif (ref $ranker eq 'CODE') { } 0 0 0
Condition33%1/3
ref $ranker eq "" and &looks_like_number($ranker)
!ll&&!rl&&r
008
MC/DC0%0/2
ref $ranker eq "" and &looks_like_number($ranker)
ref $ranker eq "" &looks_like_number($ranker)
Truth table33%1/3
A and B
A= ref $ranker eq ""B= &looks_like_number($ranker)
ABresult
0X0
100
111
14 8 return Algorithm::BestChoice::Ranker::Value->new( value => $ranker );
15 }
16 elsif (ref $ranker eq 'CODE') {
17 0 return Algorithm::BestChoice::Ranker::Code->new( code => $ranker );
18 }
19  
20 0 die "Don't understand ranker $ranker";
21 }
22  
23 0 ▶sub rank {
Subroutine rank: not called CC=1 SCAR=6.9
Pod undocumented
24 0 die "Unspecific ranker can't rank";
25 }
26  
27 package Algorithm::BestChoice::Ranker::Value;
28  
29 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 3 extends qw/Algorithm::BestChoice::Ranker/;
32  
33 3 has value => qw/is ro required 1 isa Num/;
34  
35 27 ▶sub rank {
Subroutine rank: called CC=1 SCAR=0.0
Pod undocumented
36 27 my $self = shift;
37 27 return $self->value;
38 }
39  
40 package Algorithm::BestChoice::Ranker::Code;
41  
42 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 3 extends qw/Algorithm::BestChoice::Ranker/;
45  
46 3 has code => qw/is ro required 1 isa CodeRef/;
47  
48 0 ▶sub rank {
Subroutine rank: not called CC=1 SCAR=6.9
Pod undocumented
49 0 my $self = shift;
50 0 my $key = shift;
51  
52 0 return $self->code( $key );
53 }
54  
55 3 1;
« BestChoice.pm ↑ Summary BestChoice/Matcher.pm »