blib/lib/Game/Floppy/Error.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 6 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 89.5% 60 / 67 CC 7 SCAR 9.0
CC
7
Cov
91%
of
4.1
BUILD
4.1
__ANON__
1.0
CRAP 2.5
« blib/lib/Game/Floppy/Bot.pm ↑ Summary bin/floppy »
1 package Game::Floppy::Error;
2  
3 16 ▶use 5.014;
Subroutine __ANON__: called CC=1 SCAR=0.0
4 16 ▶use strict;
Subroutine __ANON__: called CC=1 SCAR=0.0
5 16 ▶use warnings;
Subroutine __ANON__: called CC=1 SCAR=0.0
6  
7 16 ▶use Carp ();
Subroutine __ANON__: called CC=1 SCAR=0.0
8 16 ▶use Object::Proto::Sugar -types;
Subroutine __ANON__: called CC=1 SCAR=0.0
9  
10 16 our $VERSION = '0.10';
11  
12 16 our (@CODES, %MESSAGE);
13  
14 16 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
15 16 @CODES = qw/ not_active already_flapped /;
16  
17 16 %MESSAGE = (
18 not_active => 'this game has finished',
19 already_flapped => 'one flap a tick',
20 );
21 }
22  
23 has code => (
24 is => 'ro',
25 isa => Str
26 16 );
27  
28 has message => (
29 is => 'ro',
30 isa => Str
31 16 );
32  
33 has error => (
34 is => 'ro',
35 default => 1
36 16 );
37  
38 5 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=14.1
Pod undocumented
39 5 my ($self) = @_;
40 5 my $code = $self->code;
41 Carp::croak("Game::Floppy::Error: '" . (defined $code ? $code : 'undef')
42 . "' is not a code")
43 5 ▶ unless defined $code && $MESSAGE{$code};
Branch: 2 branches
BranchTrueFalseTotal
unless defined $code and $Game::Floppy::Error::MESSAGE{$code} 1 4 5
defined $code ? : 1 0 1
Condition66%2/3
defined $code and $Game::Floppy::Error::MESSAGE{$code}
!ll&&!rl&&r
014
MC/DC50%1/2
defined $code and $Game::Floppy::Error::MESSAGE{$code}
defined $code $Game::Floppy::Error::MESSAGE{$code}
Truth table66%2/3
A and B
A= defined $codeB= $Game::Floppy::Error::MESSAGE{$code}
ABresult
0X0
100
111
44 4 return;
45 }
46  
47 5 ▶sub of {
Subroutine of: called CC=4 SCAR=14.2
Pod documented
48 5 my ($class, $code) = @_;
49 Carp::croak("Game::Floppy::Error: '" . (defined $code ? $code : 'undef')
50 . "' is not a code")
51 5 ▶ unless defined $code && $MESSAGE{$code};
Branch: 2 branches
BranchTrueFalseTotal
unless defined $code and $Game::Floppy::Error::MESSAGE{$code} 1 4 5
defined $code ? : 1 0 1
Condition66%2/3
defined $code and $Game::Floppy::Error::MESSAGE{$code}
!ll&&!rl&&r
014
MC/DC50%1/2
defined $code and $Game::Floppy::Error::MESSAGE{$code}
defined $code $Game::Floppy::Error::MESSAGE{$code}
Truth table66%2/3
A and B
A= defined $codeB= $Game::Floppy::Error::MESSAGE{$code}
ABresult
0X0
100
111
52 4 return $class->new(code => $code, message => $MESSAGE{$code});
53 }
54  
55 2 ▶sub codes { return [@CODES] }
Subroutine codes: called CC=1 SCAR=0.0
Pod documented
56  
57 1 ▶sub messages { return { %MESSAGE } }
Subroutine messages: called CC=1 SCAR=0.0
Pod documented
58  
59 1 ▶sub stringify {
Subroutine stringify: called CC=1 SCAR=0.0
Pod documented
60 1 my ($self) = @_;
61 1 return $self->code . ': ' . $self->message;
62 }
63  
64 16 1;
65  
66 __END__
« blib/lib/Game/Floppy/Bot.pm ↑ Summary bin/floppy »