Valiant/Filter/Lower.pm

filter: Statementstmt 100% 14 / 14 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 86.3% 19 / 22 CC 2 SCAR 3.4
CC
2
Cov
94%
filter_each
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Valiant/JSON/Util.pm ↑ Summary Valiant/Filter/Collapse.pm »
1 package Valiant::Filter::Lower;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Valiant::Util 'throw_exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 with 'Valiant::Filter::Each';
7  
8 sub normalize_shortcut {
9 2 ▶ my ($class, $arg) = @_;
Subroutine normalize_shortcut: called CC=1 SCAR=0.0
Pod undocumented
10 2 return +{ };
11 }
12  
13 sub filter_each {
14 2 ▶ my ($self, $class, $attrs, $attribute_name) = @_;
Subroutine filter_each: called CC=2 SCAR=7.0
Pod undocumented
15 2 my $value = $attrs->{$attribute_name};
16 2 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 2 2
17 2 return lc $value;
18 }
19  
20 2 1;
21  
22 =head1 NAME
23  
24 Valiant::Filter::Lower - lower case a string
25  
26 =head1 SYNOPSIS
27  
28 package Local::Test::User;
29  
30 use Moo;
31 use Valiant::Filters;
32  
33 has 'name' => (is=>'ro', required=>1);
34  
35 filters name => (
36 lower => 1,
37 );
38  
39 my $user = Local::Test::User->new(name=>'JOHN');
40  
41 print $user->name; # 'john'
42
43 =head1 DESCRIPTION
44  
45 This is a very simple filter that takes no paramters and just does a 'lc' on the
46 value of the attribute.
47  
48 =head1 SEE ALSO
49
50 L<Valiant>, L<Valiant::Filter>, L<Valiant::Validator::Filter>.
51  
52 =head1 AUTHOR
53
54 See L<Valiant>
55
56 =head1 COPYRIGHT & LICENSE
57
58 See L<Valiant>
59  
60 =cut
« Valiant/JSON/Util.pm ↑ Summary Valiant/Filter/Collapse.pm »