lib/Template/Plugin/Format.pm

filter: Statementstmt 100% 19 / 19 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 93.9% 31 / 33 CC 4 SCAR 5.1
CC
4
Cov
96%
make_formatter
2.0
new
2.0
__ANON__
2.0
CRAP 1.7
« lib/Template/Plugin/Math.pm ↑ Summary lib/Template/Plugin.pm »
1 #============================================================= -*-Perl-*-
2 #
3 # Template::Plugin::Format
4 #
5 # DESCRIPTION
6 #
7 # Simple Template Toolkit Plugin which creates formatting functions.
8 #
9 # AUTHOR
10 # Andy Wardley <abw@wardley.org>
11 #
12 # COPYRIGHT
13 # Copyright (C) 1996-2022 Andy Wardley. All Rights Reserved.
14 #
15 # This module is free software; you can redistribute it and/or
16 # modify it under the same terms as Perl itself.
17 #
18 #============================================================================
19  
20 package Template::Plugin::Format;
21  
22 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use base 'Template::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 2 our $VERSION = '3.100';
27  
28  
29 sub new {
30 7 ▶ my ($class, $context, $format) = @_;;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
31 7 ▶ return defined $format
Branch: 1 branch
BranchTrueFalseTotal
defined $format ? : 6 1 7
32 ? make_formatter($format)
33 : \&make_formatter;
34 }
35  
36  
37 sub make_formatter {
38 8 ▶ my $format = shift;
Subroutine make_formatter: called CC=2 SCAR=7.0
Pod undocumented
39 8 ▶ $format = '%s' unless defined $format;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $format 0 8 8
40 return sub {
41 18 ▶ my @args = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
42 18 ▶ push(@args, '') unless @args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 1 17 18
43 18 return sprintf($format, @args);
44 }
45 8 }
46  
47  
48 2 1;
49  
50 __END__
« lib/Template/Plugin/Math.pm ↑ Summary lib/Template/Plugin.pm »