Class/Backwards.pm

filter: Statementstmt 51.8% 14 / 27 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 60.0% 3 / 5 Podpod 50.0% 1 / 2 totaltotal 33.9% 18 / 53 CC 8 SCAR 35.2
CC
8
Cov
33%
error
56.0
warning
6.0
BEGIN
1.0
CRAP 33.9
↑ Summary Class/Exporter.pm »
1 # ABSTRACT: Backwards-Compatibility Layer for Validation::Class
2  
3 package Validation::Class::Backwards;
4 {
5 56 $Validation::Class::Backwards::VERSION = '7.10_01';
6 }
7  
8 56 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 56 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 56 our $VERSION = '7.10_01'; # VERSION
12  
13 56 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 56 $ENV{'VALIDATION_CLASS_BC_WARNING'} = <<'WARNING'; # usage warning
16 The method you're attempting to use is (or will be) DEPRECIATED.
17 WARNING
18  
19 sub warning {
20 warn $ENV{'VALIDATION_CLASS_BC_WARNING'}
21 0 ▶ if $ENV{'VALIDATION_CLASS_BC_WARNING'}
Subroutine warning: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"VALIDATION_CLASS_BC_WARNING"} 0 0 0
22 }
23  
24  
25  
26 0 ▶sub error { warning();
Subroutine error: not called CC=7 SCAR=40.3
Pod documented
27
28 0 my ( $self, @args ) = @_;
29  
30 # set an error message on a particular field
31 0 ▶ if ( @args == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 2) 0 0 0
32
33 # set error message
34 0 my ( $field, $error ) = @args;
35
36 # field must be a reference (hashref) to a field object
37 0 ▶ if ( ref($field) && ( !ref($error) && $error ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $field and (not ref $error and $error)) { } 0 0 0
Condition0%0/6
ref $field and (not ref $error and $error)
!ll&&!rl&&r
000
not ref $error and $error
!ll&&!rl&&r
000
MC/DC0%0/3
ref $field and (not ref $error and $error)
ref $field not ref $error $error
Truth table0%0/4
A and not(B) and C
A= ref $fieldB= not ref $errorC= $error
ABCresult
0XX0
10X0
1100
1111
38
39 # temporary, may break stuff
40 0 ▶ $error = $field->{error} if defined $field->{error};
Branch: 1 branch
BranchTrueFalseTotal
if defined $field->{"error"} 0 0 0
41
42 # add error to field-level errors
43 0 $field->{errors}->add($error);
44
45 # add error to class-level errors
46 0 $self->errors->add($error);
47
48 }
49 else {
50
51 0 confess "Can't set error without proper field object, "
52 . "field must be a hashref with name and value keys";
53
54 }
55
56 }
57
58 # retrieve an error message on a particular field
59 0 ▶ if ( @args == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 1) 0 0 0
60  
61 # add error to class-level errors
62 0 $self->errors->add($args[0]);
63
64 }
65
66 # return all class-level error messages
67 0 return $self->errors->all;
68
69 }
70  
71 56 1;
72 __END__
↑ Summary Class/Exporter.pm »