lib/Data/Validation/Utils.pm

filter: Statementstmt 100% 37 / 37 Branchbran 50.0% 3 / 4 (1 uncoverable) Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 3 / 3 totaltotal 96.4% 55 / 56 (1 uncoverable) CC 3 SCAR 2.6
CC
3
Cov
95%
ensure_class_loaded
2.1
load_class
2.0
BEGIN
1.0
CRAP 1.3
« lib/Data/Validation/Constraints/Email.pm ↑ Summary
1 package Data::Validation::Utils;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use parent 'Exporter::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Data::Validation::Constants qw( EXCEPTION_CLASS TRUE );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Module::Runtime qw( require_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Unexpected::Functions qw( is_class_loaded );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @EXPORT_OK = qw( ensure_class_loaded load_class throw );
13  
14 39 ▶sub ensure_class_loaded ($) {
Subroutine ensure_class_loaded: called CC=2 SCAR=7.2
Pod documented
15 39 my $class = shift;
16  
17 39 ▶ try { require_module( $class ) } catch { throw( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
18  
19 # uncoverable branch true
20 38 ▶ is_class_loaded( $class )
Branch: 1 branch
BranchTrueFalseTotal
&is_class_loaded($class) or &throw("Class [_1] loaded but package undefined", [$class]) 38 0 38
21 or throw( 'Class [_1] loaded but package undefined', [ $class ] );
22  
23 38 return TRUE;
24 }
25  
26 34 ▶sub load_class ($$$) {
Subroutine load_class: called CC=2 SCAR=6.9
Pod documented
27 34 my ($proto, $prefix, $class) = @_; $class =~ s{ \A $prefix }{}mx;
28  
29 34 ▶ if ('+' eq substr $class, 0, 1) { $class = substr $class, 1 }
Branch: 1 branch
BranchTrueFalseTotal
if ('+' eq substr($class, 0, 1)) { } 3 31 34
30 31 else { $class = "${proto}::".(ucfirst $class) }
31  
32 34 ensure_class_loaded $class;
33  
34 33 return $class;
35 }
36  
37 50 ▶sub throw (;@) {
Subroutine throw: called CC=1 SCAR=0.0
Pod documented
38 50 EXCEPTION_CLASS->throw( @_ );
39 }
40  
41 1 1;
42  
43 __END__
« lib/Data/Validation/Constraints/Email.pm ↑ Summary