Boundary/Types.pm

filter: Statementstmt 89.1% 33 / 37 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod n/a totaltotal 81.1% 43 / 53 CC 4 SCAR 13.1
CC
4
Cov
79%
__ANON__
12.0
__ANON__
2.0
__ANON__
1.1
CRAP 3.7
↑ Summary Boundary.pm »
1 package Boundary::Types;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Type::Library -base,
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 -declare => qw( ImplOf );
7  
8 2 ▶use Boundary ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Class::Load qw(is_class_loaded);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 __PACKAGE__->add_type({
15 name => 'ImplOf',
16 parent => Object,
17 1 ▶ constraint_generator => sub {
Subroutine __ANON__: called CC=1 SCAR=1.0
18 1 my $self = $Type::Tiny::parameterize_type;
19 1 my @interfaces = @_;
20  
21 1 my $display_name = $self->name_generator->($self, @interfaces);
22  
23 my %options = (
24 4 ▶ constraint => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
25 4 my ($target) = @_;
26 4 my $impl = blessed($target);
27 4 ▶ return if !$impl;
Branch: 1 branch
BranchTrueFalseTotal
unless $impl 0 4 4
28 4 return Boundary->check_implementations($impl, @interfaces);
29 },
30 display_name => $display_name,
31 parameters => [@interfaces],
32 0 ▶ message => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
33 0 my $impl = blessed($_);
34 0 ▶ return "$_ is not blessed" if !$impl;
Branch: 1 branch
BranchTrueFalseTotal
unless $impl 0 0 0
35 0 ▶ return "$impl not loaded" if !is_class_loaded($impl);
Branch: 1 branch
BranchTrueFalseTotal
unless is_class_loaded($impl) 0 0 0
36 0 return sprintf '%s did not pass type constraint "%s"', Type::Tiny::_dd($_), $display_name;
37 },
38 1 );
39  
40 1 return $self->create_child_type(%options);
41 },
42 2 });
43  
44 2 __PACKAGE__->meta->make_immutable;
45  
46 2 1;
↑ Summary Boundary.pm »