Dominoes/Boneyard.pm

filter: Statementstmt 91.1% 31 / 34 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 81.8% 9 / 11 Podpod 87.5% 7 / 8 totaltotal 84.1% 53 / 63 CC 7 SCAR 8.1
CC
7
Cov
84%
is_empty
6.0
BUILD
2.0
draw
2.0
CRAP 2.2
« Dominoes/Result.pm ↑ Summary
1 package Game::Dominoes::Boneyard;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 our $VERSION = '0.03';
9  
10 has tiles => (
11 is => 'rw',
12 isa => ArrayRef,
13 default => []
14 12 );
15  
16 has reserve => (
17 is => 'rw',
18 isa => Int,
19 default => 0
20 12 );
21  
22 2243 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.1
Pod undocumented
23 2243 my ($self) = @_;
24 2243 ▶ die 'Game::Dominoes::Boneyard: reserve must not be negative'
Branch: 1 branch
BranchTrueFalseTotal
if $self->reserve < 0 0 2243 2243
25 if $self->reserve < 0;
26 2243 return $self;
27 }
28  
29 8708 ▶sub count {
Subroutine count: called CC=1 SCAR=0.0
Pod documented
30 8708 return scalar @{ $_[0]->tiles };
31 }
32  
33 7941 ▶sub drawable {
Subroutine drawable: called CC=2 SCAR=6.9
Pod documented
34 7941 my ($self) = @_;
35 7941 my $n = $self->count - $self->reserve;
36 7941 ▶ return $n > 0 ? $n : 0;
Branch: 1 branch
BranchTrueFalseTotal
$n > 0 ? : 7512 429 7941
37 }
38  
39 0 ▶sub is_empty {
Subroutine is_empty: not called CC=2 SCAR=17.9
Pod documented
40 0 ▶ return $_[0]->count ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->count ? : 0 0 0
41 }
42  
43 7941 ▶sub can_draw {
Subroutine can_draw: called CC=2 SCAR=6.9
Pod documented
44 7941 ▶ return $_[0]->drawable ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->drawable ? : 7512 429 7941
45 }
46  
47 3756 ▶sub draw {
Subroutine draw: called CC=2 SCAR=7.0
Pod documented
48 3756 my ($self) = @_;
49 3756 ▶ return undef unless $self->can_draw;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can_draw 0 3756 3756
50 3756 return shift @{ $self->tiles };
51 }
52  
53 0 ▶sub peek {
Subroutine peek: not called CC=1 SCAR=6.9
Pod documented
54 0 return [ @{ $_[0]->tiles } ];
55 }
56  
57 885 ▶sub pips {
Subroutine pips: called CC=2 SCAR=6.9
Pod documented
58 885 my ($self) = @_;
59 885 my $total = 0;
60 885 $total += $_->pips for @{ $self->tiles };
61 885 return $total;
62 }
63  
64 12 1;
65  
66 __END__
« Dominoes/Result.pm ↑ Summary