Signature/Path.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 92.3% 48 / 52 CC 5 SCAR 6.3
CC
5
Cov
90%
BUILD
3.1
extract
2.0
append
2.0
CRAP 1.9
« Signature.pm ↑ Summary Signature/Query.pm »
1 package URL::Signature::Path;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent 'URL::Signature';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Params::Util qw( _NONNEGINT );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.03';
9  
10  
11 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
12 1 my ($class, %attrs) = @_;
13 1 return $class->SUPER::new( %attrs, format => 'path' );
14 }
15  
16 2 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.4
Pod documented
17 2 my $self = shift;
18 2 ▶ $self->{'as'} = 1 unless exists $self->{'as'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"as"} 2 0 2
19 Carp::croak( q[in 'path' format, 'as' needs to be a non-negative integer])
20 2 ▶ unless defined _NONNEGINT($self->{'as'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined &_NONNEGINT($self->{"as"}) 0 2 2
21  
22 2 return;
23 }
24  
25  
26 3 ▶sub extract {
Subroutine extract: called CC=2 SCAR=7.0
Pod documented
27 3 my ($self, $uri) = @_;
28 3 my @segments = $uri->path_segments;
29 3 ▶ return if scalar @segments <= $self->{'as'};
Branch: 1 branch
BranchTrueFalseTotal
if scalar @segments <= $self->{"as"} 0 3 3
30  
31 3 my $code = splice @segments, $self->{'as'}, 1;
32 3 $uri->path_segments( @segments );
33  
34 3 return ($code, $uri);
35 }
36  
37  
38 3 ▶sub append {
Subroutine append: called CC=2 SCAR=7.0
Pod documented
39 3 my ($self, $uri, $code) = @_;
40 3 my @segments = $uri->path_segments;
41 3 ▶ return if scalar @segments <= $self->{'as'};
Branch: 1 branch
BranchTrueFalseTotal
if scalar @segments <= $self->{"as"} 0 3 3
42 3 splice @segments, $self->{'as'}, 0, $code;
43 3 $uri->path_segments(@segments);
44 3 return $uri;
45 }
46  
47  
48 2 42;
49 __END__
« Signature.pm ↑ Summary Signature/Query.pm »