| 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)!])
MC/DC0%0/1
shift() || confess(q['create_href' expects 1 or 2 variables (got nothing)!])
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 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)!])
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]
| |||||||||||||||||||||||||||||
| 23 | 5 | my $text = $hash->fetch($text_key); | |||||||||||||||||||||||||||
| 24 | 5 | ▶ | my $start = $args[1] || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args[1] || 0
MC/DC100%1/1
$args[1] || 0
$args[1]
Truth table100%2/2
A
A= $args[1]
| |||||||||||||||||||||||||||||
| 25 | 5 | ▶ | my $len = $args[2] || length($text); | ||||||||||||||||||||||||||
|
Condition66%2/3
$args[2] || length $text
MC/DC0%0/2
$args[2] || length $text
$args[2]
length $text
Truth table66%2/3
A || B
A= $args[2]B= length $text
| |||||||||||||||||||||||||||||
| 26 | 5 | ▶ | my $ellipsis = $args[3] || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args[3] || 0
MC/DC100%1/1
$args[3] || 0
$args[3]
Truth table100%2/2
A
A= $args[3]
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 5 | my $new_text = substr($text, $start, $len); | |||||||||||||||||||||||||||
| 29 | 5 | ▶ | if ( $ellipsis && (length($new_text) >= ($len - $start)) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ellipsis and length $new_text >= $len - $start
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
| |||||||||||||||||||||||||||||
| 30 | 2 | $new_text .= "..."; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 5 | return $new_text; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 5 | 1; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | __END__ | ||||||||||||||||||||||||||||