Utils/Substr.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 2 / 2 Conditioncond 71.4% 10 / 14 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 84.8% 56 / 66 CC 8 SCAR 16.3
CC
8
Cov
92%
process
8.2
BEGIN
1.0
BEGIN
1.0
CRAP 5.1
« Utils/Equal.pm ↑ Summary Utils/If.pm »
1 package Petal::Utils::Substr;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use base qw( Petal::Utils::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶use constant name => 'substr';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use constant aliases => qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
14 5 our $REVISION = (split(/ /, ' $Revision: 1.2 $ '))[2];
15  
16 5 ▶sub process {
Subroutine process: called CC=8 SCAR=21.0
Pod undocumented
17 5 my $class = shift;
18 5 my $hash = shift;
19 5 ▶ my $args = shift || confess( "'create_href' expects 1 or 2 variables (got nothing)!" );
Condition50%1/2
shift() || confess(q['create_href' expects 1 or 2 variables (got nothing)!])
l!l
50
MC/DC0%0/1
shift() || confess(q['create_href' expects 1 or 2 variables (got nothing)!])
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
20  
21 5 my @args = $class->split_args( $args );
22 5 ▶ my $text_key = $args[0] || confess( "1st arg to 'limit' should be a variable (got nothing)!" );
Condition50%1/2
$args[0] || confess(q[1st arg to 'limit' should be a variable (got nothing)!])
l!l
50
MC/DC0%0/1
$args[0] || confess(q[1st arg to 'limit' should be a variable (got nothing)!])
$args[0]
Truth table50%1/2
A
A= $args[0]
Aresult
11
00
23 5 my $text = $hash->fetch($text_key);
24 5 ▶ my $start = $args[1] || 0;
Condition100%2/2
$args[1] || 0
l!l
41
MC/DC100%1/1
$args[1] || 0
$args[1]
Truth table100%2/2
A
A= $args[1]
Aresult
11
00
25 5 ▶ my $len = $args[2] || length($text);
Condition66%2/3
$args[2] || length $text
l!l&&r!l&&!r
320
MC/DC0%0/2
$args[2] || length $text
$args[2] length $text
Truth table66%2/3
A || B
A= $args[2]B= length $text
ABresult
1X1
011
000
26 5 ▶ my $ellipsis = $args[3] || 0;
Condition100%2/2
$args[3] || 0
l!l
23
MC/DC100%1/1
$args[3] || 0
$args[3]
Truth table100%2/2
A
A= $args[3]
Aresult
11
00
27  
28 5 my $new_text = substr($text, $start, $len);
29 5 ▶ if ( $ellipsis && (length($new_text) >= ($len - $start)) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ellipsis and length $new_text >= $len - $start) 2 3 5
Condition66%2/3
$ellipsis and length $new_text >= $len - $start
!ll&&!rl&&r
302
MC/DC50%1/2
$ellipsis and length $new_text >= $len - $start
$ellipsis length $new_text >= $len - $start
Truth table66%2/3
A and B
A= $ellipsisB= length $new_text >= $len - $start
ABresult
0X0
100
111
30 2 $new_text .= "...";
31 }
32 5 return $new_text;
33  
34 }
35  
36 5 1;
37  
38 __END__
« Utils/Equal.pm ↑ Summary Utils/If.pm »