Gin/Hand.pm

filter: Statementstmt 100% 38 / 38 Branchbran 75.0% 6 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 12 / 12 Podpod 100% 8 / 8 totaltotal 94.3% 67 / 71 CC 6 SCAR 6.1
CC
6
Cov
94%
has_card
3.0
remove
3.0
full
2.1
CRAP 1.8
« Gin/Card.pm ↑ Summary Gin/Error.pm »
1 package Game::Gin::Hand;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 ▶use Game::Gin::Deadwood ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 our $VERSION = '0.03';
11  
12 10 has cards => (is => 'rw', isa => ArrayRef);
13  
14 35858 ▶sub count { return scalar @{ $_[0]->cards } }
Subroutine count: called CC=1 SCAR=0.0
Pod documented
15 12 ▶sub full { return $_[0]->count > 10 ? 1 : 0 }
Subroutine full: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->count > 10 ? : 12 0 12
16  
17 29579 ▶sub has_card {
Subroutine has_card: called CC=3 SCAR=11.0
Pod documented
18 29579 my ($self, $card) = @_;
19 29579 ▶ return 0 unless defined $card;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $card 0 29579 29579
20 29579 ▶ return scalar(grep { $_ == $card } @{ $self->cards }) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
scalar grep({$_ == $card;} @{$self->cards;}) ? : 29576 3 29579
21 }
22  
23 29596 ▶sub add {
Subroutine add: called CC=1 SCAR=0.0
Pod documented
24 29596 my ($self, $card) = @_;
25 29596 $self->cards([ @{ $self->cards }, $card ]);
26 29596 return $self;
27 }
28  
29 29575 ▶sub remove {
Subroutine remove: called CC=3 SCAR=11.0
Pod documented
30 29575 my ($self, $card) = @_;
31 29575 my $seen = 0;
32 29575 ▶ $self->cards([ grep { $_ == $card && !$seen++ ? 0 : 1 } @{ $self->cards } ]);
Branch: 1 branch
BranchTrueFalseTotal
$_ == $card && !$seen++ ? : 29575 295750 325325
Condition66%2/3
$_ == $card and not $seen++
!ll&&!rl&&r
295750029575
MC/DC50%1/2
$_ == $card and not $seen++
$_ == $card not $seen++
Truth table66%2/3
A and not(B)
A= $_ == $cardB= not $seen++
ABresult
0X0
100
111
33 29575 return $self;
34 }
35  
36 2021 ▶sub best { return Game::Gin::Deadwood::best($_[0]->cards) }
Subroutine best: called CC=1 SCAR=0.0
Pod documented
37 57197 ▶sub deadwood { return Game::Gin::Deadwood::deadwood($_[0]->cards) }
Subroutine deadwood: called CC=1 SCAR=0.0
Pod documented
38  
39 2 ▶sub sorted { return [ sort { $a <=> $b } @{ $_[0]->cards } ] }
Subroutine sorted: called CC=1 SCAR=0.0
Pod documented
40  
41 10 1;
42  
43 __END__
« Gin/Card.pm ↑ Summary Gin/Error.pm »