blib/lib/MooX/MouseTypeConstraints.pm

filter: Statementstmt 100% 43 / 43 Branchbran 90.0% 9 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 13 / 13 Podpod n/a totaltotal 92.9% 66 / 71 CC 7 SCAR 5.7
CC
7
Cov
95%
__ANON__
3.2
__ANON__
2.0
_generate_isa
2.0
CRAP 1.8
↑ Summary
1 package MooX::MouseTypeConstraints;
2 3 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = "0.01";
7  
8 3 ▶use B::Hooks::EndOfScope;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Mouse::Util::TypeConstraints ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
12 5 my $class = shift;
13 5 my $target = caller;
14  
15 5 ▶ on_scope_end {
Subroutine __ANON__: called CC=2 SCAR=7.0
16 5 ▶ my $has = $target->can('has')
Branch: 1 branch
BranchTrueFalseTotal
my $has = $target->can("has") or die "Moo's internal DSL keyword `has` is not found. (perhaps you forgot to load \"Moo\"?)" 4 1 5
17 or die q|Moo's internal DSL keyword `has` is not found. (perhaps you forgot to load "Moo"?)|;
18 4 ▶ my $code = sub {
Subroutine __ANON__: called CC=3 SCAR=11.6
19 4 my ($name, %args) = @_;
20 4 ▶ if (exists $args{isa} && !ref $args{isa}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"isa"} and not ref $args{"isa"}) 4 0 4
Condition33%1/3
exists $args{"isa"} and not ref $args{"isa"}
!ll&&!rl&&r
004
MC/DC0%0/2
exists $args{"isa"} and not ref $args{"isa"}
exists $args{"isa"} not ref $args{"isa"}
Truth table33%1/3
A and not(B)
A= exists $args{"isa"}B= not ref $args{"isa"}
ABresult
0X0
100
111
21 4 my $type = Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint($args{isa});
22 4 $args{isa} = _generate_isa($type);
23 }
24 4 @_ = ($name, %args);
25 4 goto $has;
26 4 };
27  
28 4 my $glob = "${target}::has";
29 {
30 3 ▶ no strict qw/refs/;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 3 ▶ no warnings qw/prototype redefine/;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 4 *{$glob} = $code;
33 };
34 5 };
35 }
36  
37 4 ▶sub _generate_isa {
Subroutine _generate_isa: called CC=2 SCAR=6.9
38 4 my $type = shift;
39 4 ▶ if ($type->has_coercion) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->has_coercion) { } 1 3 4
40 3 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
41 3 ▶ die $type->get_message(@_) unless $type->check($type->coerce(@_));
Branch: 1 branch
BranchTrueFalseTotal
unless $type->check($type->coerce(@_)) 1 2 3
42 1 };
43 } else {
44 8 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
45 8 ▶ die $type->get_message(@_) unless $type->check(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless $type->check(@_) 2 6 8
46 3 };
47 }
48 }
49  
50 3 1;
51 __END__
↑ Summary