blib/lib/String/Cushion.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 86.0% 37 / 43 CC 5 SCAR 12.0
CC
5
Cov
89%
cushion
5.2
BEGIN
1.0
BEGIN
1.0
CRAP 3.3
↑ Summary
1 2 ▶use 5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 package String::Cushion;
5  
6 # ABSTRACT: Vertically pad a string
7 2 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
8 2 our $VERSION = '1.0000';
9  
10 2 1;
11  
12 2 ▶use Sub::Exporter::Progressive -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
13 exports => [qw/cushion/],
14 groups => {
15 default => [qw/cushion/],
16 },
17 2 };
18  
19 8 ▶sub cushion($$;$) {
Subroutine cushion: called CC=5 SCAR=16.5
Pod documented
20 8 my $top_cushion = shift;
21 8 my $second = shift;
22 8 my $third = shift;
23  
24 8 ▶ my $bottom_cushion = defined $third ? $second : $top_cushion;
Branch: 1 branch
BranchTrueFalseTotal
defined $third ? : 3 5 8
25 8 ▶ my $string = defined $third ? $third : $second;
Branch: 1 branch
BranchTrueFalseTotal
defined $third ? : 3 5 8
26  
27 8 ▶ if($top_cushion !~ m{^\d+$} || $bottom_cushion !~ m{^\d+$}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($top_cushion =~ /^\d+$/ and $bottom_cushion =~ /^\d+$/) 0 8 8
Condition33%1/3
$top_cushion =~ /^\d+$/ and $bottom_cushion =~ /^\d+$/
!ll&&!rl&&r
008
MC/DC0%0/2
$top_cushion =~ /^\d+$/ and $bottom_cushion =~ /^\d+$/
$top_cushion =~ /^\d+$/ $bottom_cushion =~ /^\d+$/
Truth table33%1/3
A and B
A= $top_cushion =~ /^\d+$/B= $bottom_cushion =~ /^\d+$/
ABresult
0X0
100
111
28 0 return $string;
29 }
30  
31 8 $string =~ s{\A[\h\v]*\v(?=\h*[^\h\v])}{};
32 8 $string =~ s{([^\h\v]\V*)\v[\h\v]*\z}{$1};
33  
34 8 $string = ("\n" x $top_cushion) . $string . ("\n" x $bottom_cushion);
35  
36 8 return $string;
37 }
38  
39 2 1;
40  
41 __END__
↑ Summary