| 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
Condition66%2/3
defined $code and $Game::Floppy::Error::MESSAGE{$code}
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}
| |||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
defined $code and $Game::Floppy::Error::MESSAGE{$code}
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}
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||