MOP/Slot/Initializer.pm

filter: Statementstmt 100% 34 / 34 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 10 / 12 Podpod 100% 3 / 3 totaltotal 86.1% 56 / 65 CC 6 SCAR 6.1
CC
6
Cov
93%
BUILDARGS
3.1
CREATE
3.0
BUILD
2.0
CRAP 1.8
« MOP/Method/Attribute.pm ↑ Summary MOP/Class.pm »
1 package MOP::Slot::Initializer;
2 # ABSTRACT: A representation of a class slot initializer
3  
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use UNIVERSAL::Object::Immutable;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 ▶use MOP::Internal::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 8 our $VERSION = '0.11';
14 8 our $AUTHORITY = 'cpan:STEVAN';
15  
16 8 ▶our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object::Immutable') }
Subroutine BEGIN: called CC=1 SCAR=0.0
17 8 our %HAS; BEGIN {
18 %HAS = (
19 ▶ default => sub {},
Subroutine __ANON__: not called CC=1 SCAR=0.0
20 ▶ required => sub {},
Subroutine __ANON__: not called CC=1 SCAR=0.0
21 )
22 8 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 sub BUILDARGS {
25 4 ▶ my $class = shift;
Subroutine BUILDARGS: called CC=3 SCAR=11.3
Pod documented
26 4 my $args = $class->SUPER::BUILDARGS( @_ );
27  
28 Carp::confess('Cannot have both a default and be required in the same initializer')
29 4 ▶ if $args->{default} && $args->{required};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"default"} and $args->{"required"} 0 4 4
Condition66%2/3
$args->{"default"} and $args->{"required"}
!ll&&!rl&&r
310
MC/DC0%0/2
$args->{"default"} and $args->{"required"}
$args->{"default"} $args->{"required"}
Truth table66%2/3
A and B
A= $args->{"default"}B= $args->{"required"}
ABresult
0X0
100
111
30  
31 4 return $args;
32 }
33  
34 sub CREATE {
35 4 ▶ my ($class, $args) = @_;
Subroutine CREATE: called CC=3 SCAR=11.0
Pod documented
36  
37 4 my $code;
38 4 ▶ if ( my $message = $args->{required} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $message = $args->{'required'}) { } 1 3 4
39 1 $code = eval 'sub { die \''.$message.'\' }';
40 }
41 else {
42 3 ▶ $code = $args->{default} || eval 'sub { undef }';
Condition66%2/3
$args->{'default'} || eval 'sub { undef }'
l!l&&r!l&&!r
120
MC/DC0%0/2
$args->{'default'} || eval 'sub { undef }'
$args->{'default'} eval 'sub { undef }'
Truth table66%2/3
A || B
A= $args->{'default'}B= eval 'sub { undef }'
ABresult
1X1
011
000
43 }
44  
45 4 return $code;
46 }
47  
48 sub BUILD {
49 4 ▶ my ($self, $params) = @_;
Subroutine BUILD: called CC=2 SCAR=6.9
Pod documented
50  
51 MOP::Internal::Util::SET_COMP_STASH_FOR_CV( $self, $params->{within_package} )
52 4 ▶ if $params->{within_package};
Branch: 1 branch
BranchTrueFalseTotal
if $params->{"within_package"} 2 2 4
53 }
54  
55 8 1;
56  
57 __END__
« MOP/Method/Attribute.pm ↑ Summary MOP/Class.pm »