blib/lib/Moose/Exception/AttributeIsRequired.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 92.8% 26 / 28 CC 3 SCAR 9.2
CC
3
Cov
96%
_build_message
3.0
BEGIN
1.0
CRAP 2.5
« blib/lib/Class/MOP/Module.pm ↑ Summary blib/lib/Moose/Exception/InvalidArgumentToMethod.pm »
1 package Moose::Exception::AttributeIsRequired;
2 14 our $VERSION = '2.4001';
3  
4 14 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 extends 'Moose::Exception';
6 14 with 'Moose::Exception::Role::Class';
7  
8 14 has 'attribute_name' => (
9 is => 'ro',
10 isa => 'Str',
11 required => 1,
12 documentation => "This attribute can be used for fetching attribute instance:\n".
13 " my \$class = Moose::Util::find_meta( \$exception->class_name );\n".
14 " my \$attribute = \$class->get_attribute( \$exception->attribute_name );\n",
15 );
16  
17 14 has 'attribute_init_arg' => (
18 is => 'ro',
19 isa => 'Str',
20 );
21  
22 14 has 'params' => (
23 is => 'ro',
24 isa => 'HashRef',
25 predicate => 'has_params',
26 );
27  
28 60 ▶sub _build_message {
Subroutine _build_message: called CC=3 SCAR=11.0
29 60 my $self = shift;
30  
31 60 my $name = $self->attribute_name;
32 60 my $msg = "Attribute ($name)";
33  
34 60 my $init_arg = $self->attribute_init_arg;
35 60 ▶ if ( defined $init_arg && $name ne $init_arg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $init_arg and $name ne $init_arg) 1 59 60
Condition66%2/3
defined $init_arg and $name ne $init_arg
!ll&&!rl&&r
0591
MC/DC50%1/2
defined $init_arg and $name ne $init_arg
defined $init_arg $name ne $init_arg
Truth table66%2/3
A and B
A= defined $init_argB= $name ne $init_arg
ABresult
0X0
100
111
36 1 $msg .= ", passed as ($init_arg),";
37 }
38  
39 60 $msg .= ' is required';
40  
41 60 return $msg;
42 }
43  
44 14 __PACKAGE__->meta->make_immutable;
45 14 1;
« blib/lib/Class/MOP/Module.pm ↑ Summary blib/lib/Moose/Exception/InvalidArgumentToMethod.pm »