lib/Template/Plugin/Format.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 90.9% 30 / 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.106';
27  
28  
29 7 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
30 7 my ($class, $context, $format) = @_;;
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 8 ▶sub make_formatter {
Subroutine make_formatter: called CC=2 SCAR=7.0
Pod undocumented
38 8 ▶ my $format = shift // '%s';
Condition50%1/2
shift() // "%s"
l!l
80
MC/DC0%0/1
shift() // "%s"
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
39 18 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
40 18 my @args = @_;
41 18 ▶ push(@args, '') unless @args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 1 17 18
42 18 return sprintf($format, @args);
43 }
44 8 }
45  
46  
47 2 1;
48  
49 __END__
« lib/Template/Plugin/Math.pm ↑ Summary lib/Template/Plugin.pm »