blib/lib/Moose/Meta/TypeCoercion/Union.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 90.0% 9 / 10 Podpod 66.6% 2 / 3 totaltotal 91.0% 51 / 56 CC 5 SCAR 6.6
CC
5
Cov
95%
compile_type_coercion
3.0
__ANON__
3.0
has_coercion_for_type
2.0
CRAP 1.9
« blib/lib/Class/MOP/Method/Accessor.pm ↑ Summary blib/lib/Moose/Meta/Role/Application/ToInstance.pm »
1 package Moose::Meta::TypeCoercion::Union;
2 398 our $VERSION = '2.4001';
3  
4 398 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 398 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 398 ▶use metaclass;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 398 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 398 ▶use parent 'Moose::Meta::TypeCoercion';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 398 ▶use Moose::Util 'throw_exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 ▶sub compile_type_coercion {
Subroutine compile_type_coercion: called CC=3 SCAR=11.0
Pod undocumented
15 5 my $self = shift;
16 5 my $type_constraint = $self->type_constraint;
17  
18 5 ▶ (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union'))
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($type_constraint) and $type_constraint->isa("Moose::Meta::TypeConstraint::Union") or throw_exception("NeedsTypeConstraintUnionForTypeCoercionUnion", "type_coercion_union_object", $self, "type_name", $type_constraint->name) 4 1 5
Condition66%2/3
builtin::blessed($type_constraint) and $type_constraint->isa("Moose::Meta::TypeConstraint::Union")
!ll&&!rl&&r
014
MC/DC50%1/2
builtin::blessed($type_constraint) and $type_constraint->isa("Moose::Meta::TypeConstraint::Union")
builtin::blessed($type_constraint) $type_constraint->isa("Moose::Meta::TypeConstraint::Union")
Truth table66%2/3
A and B
A= builtin::blessed($type_constraint)B= $type_constraint->isa("Moose::Meta::TypeConstraint::Union")
ABresult
0X0
100
111
19 || throw_exception( NeedsTypeConstraintUnionForTypeCoercionUnion => type_coercion_union_object => $self,
20 type_name => $type_constraint->name
21 );
22  
23 $self->_compiled_type_coercion(
24 7 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
25 7 my $value = shift;
26  
27 7 foreach my $type ( grep { $_->has_coercion }
28 7 @{ $type_constraint->type_constraints } ) {
29 11 my $temp = $type->coerce($value);
30 11 ▶ return $temp if $type_constraint->check($temp);
Branch: 1 branch
BranchTrueFalseTotal
if $type_constraint->check($temp) 6 5 11
31 }
32  
33 1 return $value;
34 }
35 4 );
36 }
37  
38 0 ▶sub has_coercion_for_type { 0 }
Subroutine has_coercion_for_type: not called CC=1 SCAR=6.9
Pod documented
39  
40 1 ▶sub add_type_coercions {
Subroutine add_type_coercions: called CC=1 SCAR=0.0
Pod documented
41 1 my $self = shift;
42 1 throw_exception( CannotAddAdditionalTypeCoercionsToUnion => type_coercion_union_object => $self );
43 }
44  
45 398 1;
46  
47 # ABSTRACT: The Moose Type Coercion metaclass for Unions
48  
49 __END__
« blib/lib/Class/MOP/Method/Accessor.pm ↑ Summary blib/lib/Moose/Meta/Role/Application/ToInstance.pm »