blib/lib/Game/Mahjong/Tally.pm

filter: Statementstmt 77.4% 24 / 31 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 3 / 3 totaltotal 75.5% 34 / 45 CC 4 SCAR 9.9
CC
4
Cov
74%
describe
6.0
has_fan
3.0
keys_of
2.0
CRAP 2.7
« blib/lib/Game/Mahjong/Error.pm ↑ Summary blib/lib/Game/Mahjong/Tiles.pm »
1 package Game::Mahjong::Tally;
2  
3 34 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 34 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 34 our $VERSION = '0.03';
10  
11 34 has points => (is => 'ro', isa => Int, required => 1);
12  
13 34 has basic => (is => 'ro', isa => Int, required => 1);
14  
15 34 has flowers => (is => 'ro', isa => Int, default => 0);
16  
17 34 has fans => (is => 'ro', isa => ArrayRef, default => []);
18  
19 34 has split => (is => 'ro');
20  
21 34 has minimum_met => (is => 'ro', default => 0);
22  
23 0 ▶sub keys_of { return map { $_->{key} } @{ $_[0]->fans } }
Subroutine keys_of: not called CC=1 SCAR=6.9
Pod documented
24  
25 47 ▶sub has_fan {
Subroutine has_fan: called CC=3 SCAR=11.0
Pod documented
26 47 my ($self, $key) = @_;
27 47 ▶ for my $f (@{ $self->fans }) { return $f->{times} if $f->{key} eq $key }
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"key"} eq $key 22 129 151
28 25 return 0;
29 }
30  
31 0 ▶sub describe {
Subroutine describe: not called CC=2 SCAR=17.9
Pod documented
32 0 my ($self) = @_;
33 0 ▶ return join(', ', map { $_->{name} . ($_->{times} > 1 ? " x$_->{times}" : '') . " ($_->{total})" } @{ $self->fans })
Branch: 1 branch
BranchTrueFalseTotal
$_->{'times'} > 1 ? : 0 0 0
34 . ' = ' . $self->points;
35 }
36  
37 34 1;
38  
39 __END__
« blib/lib/Game/Mahjong/Error.pm ↑ Summary blib/lib/Game/Mahjong/Tiles.pm »