blib/lib/Rose/URI.pm

filter: Statementstmt 84.9% 197 / 232 Branchbran 77.9% 106 / 136 Conditioncond 41.1% 21 / 51 MC/DCmcdc 27.5% 8 / 29 Subroutinesub 91.1% 31 / 34 Podpod 85.0% 17 / 20 totaltotal 75.7% 380 / 502 CC 93 SCAR 24.5
CC
93
Cov
77%
__uri_from_apache_uri
72.0
userinfo
20.0
__uri_from_uri
14.0
CRAP 11.6
↑ Summary
1 package Rose::URI;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use URI::Escape();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Rose::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 our @ISA = qw(Rose::Object);
10  
11 use overload
12 2 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.1
13 17 ▶ '""' => sub { shift->as_string },
Subroutine __ANON__: called CC=1 SCAR=0.0
14 0 ▶ 'bool' => sub { length shift->as_string },
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 2 fallback => 1,
16 2 );
17  
18 2 our $Make_URI;
19  
20 2 our $SCHEME_RE = '[a-zA-Z][a-zA-Z0-9.+\-]*';
21  
22 2 our $VERSION = '1.00';
23  
24 # Class data
25 use Rose::Class::MakeMethods::Generic
26 2 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 inheritable_scalar =>
28 [
29 'default_query_param_separator',
30 'default_omit_empty_query_params',
31 ],
32 2 );
33  
34 # Object data
35 use Rose::Object::MakeMethods::Generic
36 2 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 scalar =>
38 [
39 'username',
40 'password',
41 'scheme',
42 'host',
43 'port',
44 'path',
45 'fragment',
46 'query_param_separator' => { interface => 'get_set_init' },
47 ],
48 2 );
49  
50 2 __PACKAGE__->default_query_param_separator('&');
51 2 __PACKAGE__->default_omit_empty_query_params(0);
52  
53 23 ▶sub init_query_param_separator { ref(shift)->default_query_param_separator }
Subroutine init_query_param_separator: called CC=1 SCAR=0.0
Pod undocumented
54  
55 sub new
56 23 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
57 23 my($class) = shift;
58  
59 23 my $self =
60 {
61 username => '',
62 password => '',
63 scheme => '',
64 host => '',
65 port => '',
66 path => '',
67 query => {},
68 fragment => '',
69 };
70  
71 23 bless $self, $class;
72  
73 23 $self->init(@_);
74  
75 23 return $self;
76 }
77  
78 sub init
79 23 ▶{
Subroutine init: called CC=2 SCAR=7.6
Pod documented
80 23 my($self) = shift;
81  
82 23 ▶ if(@_ == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 23 0 23
83 {
84 23 $self->init_with_uri(@_);
85 }
86 else
87 {
88 0 $self->SUPER::init(@_);
89 }
90 }
91  
92 sub init_with_uri
93 23 ▶{
Subroutine init_with_uri: called CC=1 SCAR=0.0
Pod undocumented
94 23 my($self) = shift;
95  
96 23 $self->$Make_URI($_[0]);
97 }
98  
99 sub clone
100 1 ▶{
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
101 1 my($self) = shift;
102 1 return bless _deep_copy($self), ref($self);
103 }
104  
105 sub parse_query
106 27 ▶{
Subroutine parse_query: called CC=11 SCAR=25.5
Pod undocumented
107 27 my($self, $query) = @_;
108  
109 27 $self->{'query_string'} = undef;
110  
111 27 ▶ unless(defined $query && $query =~ /\S/)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $query and $query =~ /\S/) 0 27 27
Condition33%1/3
defined $query and $query =~ /\S/
!ll&&!rl&&r
0027
MC/DC0%0/2
defined $query and $query =~ /\S/
defined $query $query =~ /\S/
Truth table33%1/3
A and B
A= defined $queryB= $query =~ /\S/
ABresult
0X0
100
111
112 {
113 0 $self->{'query'} = { };
114 0 return 1;
115 }
116  
117 27 my @params;
118  
119 27 ▶ if(index($query, '&') >= 0)
Branch: 3 branches
BranchTrueFalseTotal
if (index($query, '&') != -1) { } 22 5 27
elsif (index($query, ';') != -1) { } 3 2 5
elsif (index($query, '=') == -1) { } 2 0 2
120 {
121 22 @params = split(/&/, $query);
122 }
123 elsif(index($query, ';') >= 0)
124 {
125 3 @params = split(/;/, $query);
126 }
127 elsif(index($query, '=') < 0)
128 {
129 2 $self->{'query_string'} = __unescape_uri($query);
130 2 $self->{'query'} = { $self->{'query_string'} => undef };
131 2 return 1;
132 }
133  
134 25 ▶ @params = ($query) unless(@params);
Branch: 1 branch
BranchTrueFalseTotal
unless @params 0 25 25
135  
136 25 my %query;
137  
138 25 foreach my $item (@params)
139 {
140 78 my($param, $value) = map { __unescape_uri($_) } split(/=/, $item);
141  
142 78 ▶ $param = __unescape_uri($item) unless(defined($param));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $param 0 78 78
143  
144 78 ▶ if(exists $query{$param})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $query{$param}) { } 25 53 78
145 {
146 25 ▶ if(ref $query{$param})
Branch: 1 branch
BranchTrueFalseTotal
if (ref $query{$param}) { } 0 25 25
147 {
148 0 push(@{$query{$param}}, $value);
149 }
150 else
151 {
152 25 $query{$param} = [ $query{$param}, $value ];
153 }
154 }
155 else
156 {
157 53 $query{$param} = $value;
158 }
159 }
160  
161 25 $self->{'query'} = \%query;
162  
163 25 return 1;
164 }
165  
166 sub query_hash
167 2 ▶{
Subroutine query_hash: called CC=2 SCAR=6.9
Pod documented
168 2 my($self) = shift;
169  
170 2 ▶ return (wantarray) ? %{$self->{'query'}} : { %{$self->{'query'}} };
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
171 }
172  
173 sub omit_empty_query_params
174 6 ▶{
Subroutine omit_empty_query_params: called CC=4 SCAR=13.9
Pod documented
175 6 my($self) = shift;
176  
177 6 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 5 6
178 {
179 1 ▶ return $self->{'omit_empty_query_params'} = $_[0] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 1 0 1
180 }
181  
182 return defined $self->{'omit_empty_query_params'} ?
183 5 ▶ $self->{'omit_empty_query_params'} : ref($self)->default_omit_empty_query_params;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'omit_empty_query_params'} ? : 1 4 5
184 }
185  
186 sub query_param
187 132 ▶{
Subroutine query_param: called CC=5 SCAR=16.2
Pod documented
188 132 my($self) = shift;
189  
190 132 ▶ if(@_ == 1)
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1) { } 117 15 132
elsif (@_ == 2) { } 15 0 15
191 {
192 117 ▶ return $self->{'query'}{$_[0]} if(exists $self->{'query'}{$_[0]});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"query"}{$_[0]} 115 2 117
193 2 return;
194 }
195 elsif(@_ == 2)
196 {
197 15 $self->{'query_string'} = undef;
198  
199 15 ▶ if(ref $_[1])
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[1]) 6 9 15
200 {
201 6 return $self->{'query'}{$_[0]} = [ @{$_[1]} ];
202 }
203  
204 9 return $self->{'query'}{$_[0]} = $_[1];
205 }
206  
207 0 Carp::croak "query_param() takes either one or two arguments";
208 }
209  
210 sub query_params
211 119 ▶{
Subroutine query_params: called CC=5 SCAR=16.1
Pod documented
212 119 my($self) = shift;
213  
214 119 ▶ return sort keys %{$self->{'query'}} unless(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 118 119
215  
216 118 my $params = $self->query_param(@_);
217  
218 118 ▶ $params = (ref $params) ? [ @$params ] :
Branch: 2 branches
BranchTrueFalseTotal
ref $params ? : 51 67 118
defined $params ? : 57 10 67
219 (defined $params) ? [ $params ] : [];
220  
221 118 ▶ return (wantarray) ? @$params : $params;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 109 9 118
222 }
223  
224 sub query_param_add
225 5 ▶{
Subroutine query_param_add: called CC=5 SCAR=16.2
Pod documented
226 5 my($self, $name, $value) = @_;
227  
228 5 ▶ Carp::croak "query_add_param() takes two arguments" unless(@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 5 5
229  
230 5 my $params = $self->query_params($name);
231  
232 5 ▶ push(@$params, (ref $value) ? @$value : $value);
Branch: 1 branch
BranchTrueFalseTotal
ref $value ? : 1 4 5
233  
234 5 ▶ $self->query_param($name => (@$params > 1) ? $params : $params->[0]);
Branch: 1 branch
BranchTrueFalseTotal
@$params > 1 ? : 3 2 5
235  
236 5 ▶ return (wantarray) ? @$params : $params;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 5 5
237 }
238  
239 sub query_param_exists
240 7 ▶{
Subroutine query_param_exists: called CC=2 SCAR=7.1
Pod documented
241 7 my($self, $param) = @_;
242  
243 7 ▶ Carp::croak "Missing query param argument" unless(defined $param);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $param 0 7 7
244  
245 7 return exists $self->{'query'}{$param};
246 }
247  
248 sub query_param_delete
249 3 ▶{
Subroutine query_param_delete: called CC=5 SCAR=16.1
Pod documented
250 3 my($self) = shift;
251  
252 3 ▶ Carp::croak "query_param_delete() takes one or more arguments" unless(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 3 3
253  
254 3 foreach my $param (@_)
255 {
256 3 ▶ if(defined $self->{'query_string'} && $param eq $self->{'query_string'})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"query_string"} and $param eq $self->{"query_string"}) 1 2 3
Condition100%3/3
defined $self->{"query_string"} and $param eq $self->{"query_string"}
!ll&&!rl&&r
111
MC/DC100%2/2
defined $self->{"query_string"} and $param eq $self->{"query_string"}
defined $self->{"query_string"} $param eq $self->{"query_string"}
Truth table100%3/3
A and B
A= defined $self->{"query_string"}B= $param eq $self->{"query_string"}
ABresult
0X0
100
111
257 {
258 1 $self->{'query_string'} = undef;
259 }
260  
261 3 delete $self->{'query'}{$param};
262 }
263 }
264  
265 sub as_string
266 31 ▶{
Subroutine as_string: called CC=6 SCAR=17.9
Pod documented
267 31 my($self) = shift;
268  
269 31 my $scheme = $self->scheme;
270 31 my $user = $self->userinfo_escaped;
271 31 my $port = $self->port;
272 31 my $query = $self->query;
273 31 my $frag = __escape_uri($self->fragment);
274  
275 31 ▶ return ((length $scheme) ? "$scheme://" : '') .
Branch: 5 branches
BranchTrueFalseTotal
length $scheme ? : 24 7 31
length $user ? : 20 11 31
length $port ? : 24 7 31
length $query ? : 31 0 31
length $frag ? : 30 1 31
276 ((length $user) ? "$user\@" : '') .
277 $self->host .
278 ((length $port) ? ":$port" : '') .
279 __escape_uri_whole($self->path) .
280 ((length $query) ? "?$query" : '') .
281 ((length $frag) ? "#$frag" : '');
282 }
283  
284 sub query
285 54 ▶{
Subroutine query: called CC=11 SCAR=24.0
Pod documented
286 54 my($self) = shift;
287  
288 54 ▶ if(@_ == 1)
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1) { } 6 48 54
elsif (@_) { } 1 47 48
289 {
290 6 ▶ if(ref $_[0])
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 2 4 6
291 {
292 2 $self->{'query'} = _deep_copy($_[0])
293 }
294 else
295 {
296 4 $self->parse_query($_[0]);
297 }
298 }
299 elsif(@_)
300 {
301 1 $self->{'query'} = _deep_copy({ @_ });
302 }
303  
304 54 my $want = wantarray;
305  
306 54 ▶ return unless(defined wantarray);
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 7 47 54
307  
308 47 ▶ if(defined $self->{'query_string'})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"query_string"}) 3 44 47
309 {
310 3 return __escape_uri($self->{'query_string'});
311 }
312  
313 44 my(@query, $omit_empty);
314  
315 44 foreach my $param (sort keys %{$self->{'query'}})
316 {
317 103 my @values = $self->query_params($param);
318  
319 # Contortions to avoid calling this method in the common(?) case where
320 # every query parameter has at least one value.
321 103 ▶ if(!@values && !(defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)))
Branch: 2 branches
BranchTrueFalseTotal
unless (@values or defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)) 4 99 103
defined $omit_empty ? : 4 4 8
Condition100%3/3
@values or defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
l!l&&r!l&&!r
9544
MC/DC100%2/2
@values or defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
@values defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
Truth table100%3/3
A or B
A= @valuesB= defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
ABresult
1X1
011
000
322 {
323 4 @values = ('');
324 }
325  
326 103 foreach my $value (@values)
327 {
328 143 push(@query, __escape_uri($param) . '=' . __escape_uri($value));
329 }
330 }
331  
332 44 return join($self->query_param_separator, @query);
333 }
334  
335 sub query_form
336 2 ▶{
Subroutine query_form: called CC=6 SCAR=17.9
Pod documented
337 2 my($self) = shift;
338  
339 2 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
340 {
341 1 $self->{'query_string'} = undef;
342 1 $self->{'query'} = { };
343  
344 1 ▶ for(my $i = 0; $i < $#_; $i += 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#_) 3 1 4
345 {
346 3 $self->query_param_add($_[$i] => $_[$i + 1]);
347 }
348 }
349  
350 2 ▶ return unless(defined(wantarray));
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 1 1 2
351  
352 1 my @query;
353  
354 1 foreach my $param ($self->query_params)
355 {
356 2 foreach my $value ($self->query_params($param))
357 {
358 3 push(@query, $param, $value);
359 }
360 }
361  
362 1 return @query;
363 }
364  
365 sub abs
366 5 ▶{
Subroutine abs: called CC=4 SCAR=14.0
Pod documented
367 5 my($self, $base) = @_;
368  
369 5 ▶ return $self unless($base && !length $self->scheme);
Branch: 1 branch
BranchTrueFalseTotal
unless $base and not length $self->scheme 1 4 5
Condition66%2/3
$base and not length $self->scheme
!ll&&!rl&&r
104
MC/DC50%1/2
$base and not length $self->scheme
$base not length $self->scheme
Truth table66%2/3
A and not(B)
A= $baseB= not length $self->scheme
ABresult
0X0
100
111
370  
371 4 my $new = $self->as_string;
372  
373 4 $new =~ s{^/}{};
374 4 $base =~ s{/$}{};
375  
376 4 ▶ return Rose::URI->new("/$new") unless($base =~ m{^$SCHEME_RE://}o);
Branch: 1 branch
BranchTrueFalseTotal
unless $base =~ m[^$Rose::URI::SCHEME_RE://]o 0 4 4
377 4 return Rose::URI->new("$base/$new");
378 }
379  
380 sub rel
381 6 ▶{
Subroutine rel: called CC=3 SCAR=11.0
Pod documented
382 6 my($self, $base) = @_;
383  
384 6 ▶ return $self unless($base);
Branch: 1 branch
BranchTrueFalseTotal
unless $base 1 5 6
385  
386 5 my $uri = $self->as_string;
387  
388 5 ▶ if($uri =~ m{^$base/?})
Branch: 1 branch
BranchTrueFalseTotal
if ($uri =~ m[^$base/?]) 2 3 5
389 {
390 2 $uri =~ s{^$base/?}{};
391  
392 2 return Rose::URI->new($uri);
393 }
394  
395 3 return $self;
396 }
397  
398 sub userinfo
399 0 ▶{
Subroutine userinfo: not called CC=4 SCAR=30.0
Pod documented
400 0 my($self) = shift;
401  
402 0 my $user = $self->username;
403 0 my $pass = $self->password;
404  
405 0 ▶ if(length $user && length $pass)
Branch: 1 branch
BranchTrueFalseTotal
if (length $user and length $pass) 0 0 0
Condition0%0/3
length $user and length $pass
!ll&&!rl&&r
000
MC/DC0%0/2
length $user and length $pass
length $user length $pass
Truth table0%0/3
A and B
A= length $userB= length $pass
ABresult
0X0
100
111
406 {
407 0 return join(':', $user, $pass);
408 }
409  
410 0 ▶ return $user if(length $user);
Branch: 1 branch
BranchTrueFalseTotal
if length $user 0 0 0
411 0 return '';
412 }
413  
414 sub userinfo_escaped
415 31 ▶{
Subroutine userinfo_escaped: called CC=4 SCAR=14.0
Pod documented
416 31 my($self) = shift;
417  
418 31 my $user = __escape_uri($self->username);
419 31 my $pass = __escape_uri($self->password);
420  
421 31 ▶ if(length $user && length $pass)
Branch: 1 branch
BranchTrueFalseTotal
if (length $user and length $pass) 20 11 31
Condition66%2/3
length $user and length $pass
!ll&&!rl&&r
11020
MC/DC50%1/2
length $user and length $pass
length $user length $pass
Truth table66%2/3
A and B
A= length $userB= length $pass
ABresult
0X0
100
111
422 {
423 20 return join(':', $user, $pass);
424 }
425  
426 11 ▶ return $user if(length $user);
Branch: 1 branch
BranchTrueFalseTotal
if length $user 0 11 11
427 11 return '';
428 }
429  
430 sub __uri_from_apache_uri
431 0 ▶{
Subroutine __uri_from_apache_uri: not called CC=8 SCAR=42.8
432 0 my($self) = shift;
433  
434 0 my $uri = Apache::URI->parse(Apache->request, @_);
435  
436 0 ▶ $self->{'username'} = $uri->user || '';
Condition0%0/2
$uri->user || ''
l!l
00
MC/DC0%0/1
$uri->user || ''
$uri->user
Truth table0%0/2
A
A= $uri->user
Aresult
11
00
437 0 ▶ $self->{'password'} = $uri->password || '';
Condition0%0/2
$uri->password || ''
l!l
00
MC/DC0%0/1
$uri->password || ''
$uri->password
Truth table0%0/2
A
A= $uri->password
Aresult
11
00
438 0 ▶ $self->{'scheme'} = $uri->scheme || '';
Condition0%0/2
$uri->scheme || ''
l!l
00
MC/DC0%0/1
$uri->scheme || ''
$uri->scheme
Truth table0%0/2
A
A= $uri->scheme
Aresult
11
00
439 0 ▶ $self->{'host'} = $uri->hostname || '';
Condition0%0/2
$uri->hostname || ''
l!l
00
MC/DC0%0/1
$uri->hostname || ''
$uri->hostname
Truth table0%0/2
A
A= $uri->hostname
Aresult
11
00
440 0 ▶ $self->{'port'} = $uri->port || '';
Condition0%0/2
$uri->port || ''
l!l
00
MC/DC0%0/1
$uri->port || ''
$uri->port
Truth table0%0/2
A
A= $uri->port
Aresult
11
00
441 0 ▶ $self->{'path'} = $uri->path || '';
Condition0%0/2
$uri->path || ''
l!l
00
MC/DC0%0/1
$uri->path || ''
$uri->path
Truth table0%0/2
A
A= $uri->path
Aresult
11
00
442 0 ▶ $self->{'fragment'} = $uri->fragment || '';
Condition0%0/2
$uri->fragment || ''
l!l
00
MC/DC0%0/1
$uri->fragment || ''
$uri->fragment
Truth table0%0/2
A
A= $uri->fragment
Aresult
11
00
443  
444 0 $self->parse_query($uri->query);
445  
446 0 return $uri;
447 }
448  
449 sub __uri_from_uri
450 23 ▶{
Subroutine __uri_from_uri: called CC=13 SCAR=26.4
451 23 my($self) = shift;
452  
453 23 my $uri = URI->new(@_);
454  
455 23 ▶ if($uri->can('user'))
Branch: 2 branches
BranchTrueFalseTotal
if ($uri->can('user')) { } 0 23 23
elsif ($uri->can('userinfo')) { } 14 9 23
456 {
457 0 $self->{'username'} = $uri->user;
458 }
459 elsif($uri->can('userinfo'))
460 {
461 14 ▶ if(my $userinfo = $uri->userinfo)
Branch: 1 branch
BranchTrueFalseTotal
if (my $userinfo = $uri->userinfo) 10 4 14
462 {
463 10 ▶ if(my($user, $pass) = split(':', $userinfo))
Branch: 1 branch
BranchTrueFalseTotal
if (() = split(/:/, $userinfo, 3)) 10 0 10
464 {
465 10 $self->{'username'} = __unescape_uri($user);
466 10 $self->{'password'} = __unescape_uri($pass);
467 }
468 }
469 }
470  
471 23 ▶ $self->{'scheme'} = __unescape_uri($uri->scheme || '');
Condition100%2/2
$uri->scheme || ''
l!l
149
MC/DC100%1/1
$uri->scheme || ''
$uri->scheme
Truth table100%2/2
A
A= $uri->scheme
Aresult
11
00
472 23 ▶ $self->{'host'} = __unescape_uri($uri->host || '') if($uri->can('host'));
Branch: 1 branch
BranchTrueFalseTotal
if $uri->can("host") 14 9 23
Condition50%1/2
$uri->host || ''
l!l
140
MC/DC0%0/1
$uri->host || ''
$uri->host
Truth table50%1/2
A
A= $uri->host
Aresult
11
00
473 23 ▶ $self->{'port'} = __unescape_uri($uri->_port || '') if($uri->can('_port'));
Branch: 1 branch
BranchTrueFalseTotal
if $uri->can("_port") 14 9 23
Condition50%1/2
$uri->_port || ''
l!l
140
MC/DC0%0/1
$uri->_port || ''
$uri->_port
Truth table50%1/2
A
A= $uri->_port
Aresult
11
00
474 23 ▶ $self->{'path'} = __unescape_uri($uri->path || '') if($uri->can('path'));
Branch: 1 branch
BranchTrueFalseTotal
if $uri->can("path") 23 0 23
Condition50%1/2
$uri->path || ''
l!l
230
MC/DC0%0/1
$uri->path || ''
$uri->path
Truth table50%1/2
A
A= $uri->path
Aresult
11
00
475 23 ▶ $self->{'fragment'} = __unescape_uri($uri->fragment || '');
Condition100%2/2
$uri->fragment || ''
l!l
203
MC/DC100%1/1
$uri->fragment || ''
$uri->fragment
Truth table100%2/2
A
A= $uri->fragment
Aresult
11
00
476  
477 23 $self->parse_query($uri->query);
478  
479 23 return $uri;
480 }
481  
482 2 ▶if(exists $ENV{'MOD_PERL'} && require mod_perl && $mod_perl::VERSION < 1.99)
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{'MOD_PERL'} and require mod_perl and $mod_perl::VERSION < 1.99) { } 0 2 2
Condition33%2/6
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
!ll&&!rl&&r
200
exists $ENV{"MOD_PERL"} and require mod_perl
!ll&&!rl&&r
200
MC/DC0%0/3
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
exists $ENV{"MOD_PERL"} require mod_perl $mod_perl::VERSION < "1.99"
Truth table25%1/4
A and B and C
A= exists $ENV{"MOD_PERL"}B= require mod_perlC= $mod_perl::VERSION < "1.99"
ABCresult
0XX0
10X0
1100
1111
483 {
484 0 require Apache;
485 0 require Apache::URI;
486 0 require Apache::Util;
487  
488 0 *__escape_uri = \&Apache::Util::escape_uri;
489 0 *__unescape_uri = \&Apache::Util::unescape_uri_info;
490  
491 0 $Make_URI = \&__uri_from_apache_uri;
492 }
493 else
494 {
495 2 *__escape_uri = \&URI::Escape::uri_escape;
496 *__unescape_uri = sub
497 273 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
498 273 my $e = URI::Escape::uri_unescape(@_);
499  
500 273 $e =~ s/\+/ /g;
501  
502 273 return $e;
503 2 };
504  
505 2 require URI;
506 2 $Make_URI = \&__uri_from_uri;
507 }
508  
509 sub __escape_uri_whole
510 31 ▶{
Subroutine __escape_uri_whole: called CC=3 SCAR=16.0
511 31 ▶ URI::Escape::uri_escape($_[0],
Branch: 2 branches
BranchTrueFalseTotal
@_ > 1 ? : 0 31 31
defined $_[1] ? : 0 0 0
512 (@_ > 1) ? (defined $_[1] ? $_[1] : ()) : q(^A-Za-z0-9\-_.,'!~*#?&()/?@\:\[\]=));
513 }
514  
515 # Based on code from Clone::PP
516 sub _deep_copy
517 10 ▶{
Subroutine _deep_copy: called CC=9 SCAR=23.6
518 10 my($data) = shift;
519  
520 10 ▶ my $ref_type = ref $data or return $data;
Branch: 1 branch
BranchTrueFalseTotal
my $ref_type = ref $data or return $data 10 0 10
521  
522 10 my $copy;
523  
524 10 ▶ if($ref_type eq 'HASH')
Branch: 4 branches
BranchTrueFalseTotal
if ($ref_type eq 'HASH') { } 5 5 10
elsif ($ref_type eq 'ARRAY') { } 4 1 5
elsif ($ref_type eq 'REF' or $ref_type eq 'SCALAR') { } 0 1 1
elsif ($ref_type->isa(__PACKAGE__)) { } 1 0 1
525 {
526 5 $copy = {};
527 5 ▶ %$copy = map { !ref($_) ? $_ : _deep_copy($_) } %$data;
Branch: 1 branch
BranchTrueFalseTotal
!ref($_) ? : 31 5 36
528 }
529 elsif($ref_type eq 'ARRAY')
530 {
531 4 $copy = [];
532 4 ▶ @$copy = map { !ref($_) ? $_ : _deep_copy($_) } @$data;
Branch: 1 branch
BranchTrueFalseTotal
!ref($_) ? : 8 0 8
533 }
534 ▶ elsif($ref_type eq 'REF' or $ref_type eq 'SCALAR')
Condition33%1/3
$ref_type eq "REF" or $ref_type eq "SCALAR"
l!l&&r!l&&!r
001
MC/DC0%0/2
$ref_type eq "REF" or $ref_type eq "SCALAR"
$ref_type eq "REF" $ref_type eq "SCALAR"
Truth table33%1/3
A or B
A= $ref_type eq "REF"B= $ref_type eq "SCALAR"
ABresult
1X1
011
000
535 {
536 0 $copy = \(my $var = '');
537 0 $$copy = _deep_copy($$data);
538 }
539 elsif($ref_type->isa(__PACKAGE__)) # cloning
540 {
541 1 $copy = _deep_copy({ %{$data} });
542 }
543 else
544 {
545 0 $copy = $data;
546 }
547  
548 10 return $copy;
549 }
550  
551 2 1;
552  
553 __END__
↑ Summary