blib/lib/Type/Coercion/Union.pm

filter: Statementstmt 88.2% 44 / 51 (1 uncoverable) Branchbran 50.0% 8 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 3 / 3 totaltotal 81.9% 67 / 83 (1 uncoverable) CC 11 SCAR 10.2
CC
11
Cov
79%
_build_moose_coercion
6.0
can_be_inlined
4.1
type_coercion_map
4.0
CRAP 2.8
« blib/lib/Type/Tie.pm ↑ Summary blib/lib/Eval/TypeTiny/CodeAccumulator.pm »
1 package Type::Coercion::Union;
2  
3 22 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 22 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 22 $Type::Coercion::Union::AUTHORITY = 'cpan:TOBYINK';
9 22 $Type::Coercion::Union::VERSION = '2.010001';
10 }
11  
12 22 $Type::Coercion::Union::VERSION =~ tr/_//d;
13  
14 22 ▶use Scalar::Util qw< blessed >;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 22 ▶use Types::TypeTiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
Subroutine _croak: called CC=1 SCAR=0.0
18  
19 22 require Type::Coercion;
20 22 our @ISA = 'Type::Coercion';
21  
22 65 ▶sub _preserve_type_constraint {
Subroutine _preserve_type_constraint: called CC=2 SCAR=7.2
23 65 my $self = shift;
24 $self->{_union_of} = $self->{type_constraint}->type_constraints
25 65 ▶ if $self->{type_constraint};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type_constraint"} 65 0 65
26 }
27  
28 1 ▶sub _maybe_restore_type_constraint {
Subroutine _maybe_restore_type_constraint: called CC=2 SCAR=7.0
29 1 my $self = shift;
30 1 ▶ if ( my $union = $self->{_union_of} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $union = $self->{"_union_of"}) 1 0 1
31 1 return Type::Tiny::Union->new( type_constraints => $union );
32 }
33 0 return; # uncoverable statement
34 }
35  
36 17 ▶sub type_coercion_map {
Subroutine type_coercion_map: called CC=4 SCAR=13.9
Pod documented
37 17 my $self = shift;
38
39 17 Types::TypeTiny::assert_TypeTiny( my $type = $self->type_constraint );
40 17 ▶ $type->isa( 'Type::Tiny::Union' )
Branch: 1 branch
BranchTrueFalseTotal
$type->isa("Type::Tiny::Union") or &_croak("Type::Coercion::Union must be used in conjunction with Type::Tiny::Union") 17 0 17
41 or _croak
42 "Type::Coercion::Union must be used in conjunction with Type::Tiny::Union";
43
44 17 my @c;
45 17 for my $tc ( @$type ) {
46 34 ▶ next unless $tc->has_coercion;
Branch: 1 branch
BranchTrueFalseTotal
unless $tc->has_coercion 2 32 34
47 32 push @c, @{ $tc->coercion->type_coercion_map };
48 }
49 17 return \@c;
50 } #/ sub type_coercion_map
51  
52 1 ▶sub add_type_coercions {
Subroutine add_type_coercions: called CC=2 SCAR=7.2
Pod documented
53 1 my $self = shift;
54 1 ▶ _croak "Adding coercions to Type::Coercion::Union not currently supported"
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 0 1
55 if @_;
56 }
57  
58 0 ▶sub _build_moose_coercion {
Subroutine _build_moose_coercion: not called CC=2 SCAR=17.9
59 0 my $self = shift;
60
61 0 my %options = ();
62 0 ▶ $options{type_constraint} = $self->type_constraint
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_type_constraint 0 0 0
63 if $self->has_type_constraint;
64
65 0 require Moose::Meta::TypeCoercion::Union;
66 0 my $r = "Moose::Meta::TypeCoercion::Union"->new( %options );
67
68 0 return $r;
69 } #/ sub _build_moose_coercion
70  
71 3 ▶sub can_be_inlined {
Subroutine can_be_inlined: called CC=4 SCAR=14.2
Pod documented
72 3 my $self = shift;
73
74 3 Types::TypeTiny::assert_TypeTiny( my $type = $self->type_constraint );
75
76 3 for my $tc ( @$type ) {
77 6 ▶ next unless $tc->has_coercion;
Branch: 1 branch
BranchTrueFalseTotal
unless $tc->has_coercion 0 6 6
78 6 ▶ return !!0 unless $tc->coercion->can_be_inlined;
Branch: 1 branch
BranchTrueFalseTotal
unless $tc->coercion->can_be_inlined 0 6 6
79 }
80
81 3 !!1;
82 } #/ sub can_be_inlined
83  
84 22 1;
85  
86 __END__
« blib/lib/Type/Tie.pm ↑ Summary blib/lib/Eval/TypeTiny/CodeAccumulator.pm »