Lite/Util/XRI.pm

filter: Statementstmt 58.1% 32 / 55 Branchbran 22.2% 4 / 18 Conditioncond 44.4% 4 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 64.2% 9 / 14 Podpod 0.0% 0 / 8 totaltotal 46.3% 51 / 110 CC 13 SCAR 21.0
CC
13
Cov
49%
root_authority
20.0
provider_is_authoritative
20.0
make_xri
6.0
CRAP 8.2
« Lite/Message.pm ↑ Summary Lite/RelyingParty/Discover/Fetcher/Yadis.pm »
1 package OpenID::Lite::Util::XRI;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 my @XRI_AUTHORITIES = qw[! = @ + $ (];
7  
8 3 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 7 ▶sub identifier_scheme {
Subroutine identifier_scheme: called CC=5 SCAR=16.4
Pod undocumented
12 7 my ( $class, $identifier ) = @_;
13 7 ▶ if ( $identifier
Branch: 1 branch
BranchTrueFalseTotal
if ($identifier and length $identifier > 0) 7 0 7
Condition33%1/3
$identifier and length $identifier > 0
!ll&&!rl&&r
007
MC/DC0%0/2
$identifier and length $identifier > 0
$identifier length $identifier > 0
Truth table33%1/3
A and B
A= $identifierB= length $identifier > 0
ABresult
0X0
100
111
14 && length($identifier) > 0 )
15 {
16 7 my $first = substr( $identifier, 0, 1 );
17 return q{xri}
18 if ( $identifier =~ /^xri:\/\//
19 7 ▶ || any { $first eq $_ } @XRI_AUTHORITIES );
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $identifier =~ m[^xri://] or &any(sub { $first eq $_; } , @XRI_AUTHORITIES) 4 3 7
Condition100%3/3
$identifier =~ m[^xri://] or &any(sub { $first eq $_; } , @XRI_AUTHORITIES)
l!l&&r!l&&!r
133
MC/DC100%2/2
$identifier =~ m[^xri://] or &any(sub { $first eq $_; } , @XRI_AUTHORITIES)
$identifier =~ m[^xri://] &any(sub { $first eq $_; } , @XRI_AUTHORITIES)
Truth table100%3/3
A or B
A= $identifier =~ m[^xri://]B= &any(sub { $first eq $_; } , @XRI_AUTHORITIES)
ABresult
1X1
011
000
20 }
21 3 return q{uri};
22 }
23  
24 1 ▶sub to_iri_normal {
Subroutine to_iri_normal: called CC=2 SCAR=7.1
Pod undocumented
25 1 my ( $class, $xri ) = @_;
26 1 ▶ $xri = sprintf( q{xri://%s}, $xri ) if $xri !~ /^xri\:\/\//;
Branch: 1 branch
BranchTrueFalseTotal
unless $xri =~ m[^xri\://] 1 0 1
27 1 return $class->escape_for_iri($xri);
28 }
29  
30 5 ▶sub escape_for_iri {
Subroutine escape_for_iri: called CC=1 SCAR=0.0
Pod undocumented
31 5 my ( $class, $xri ) = @_;
32 5 $xri =~ s/%/%25/g;
33 5 $xri =~ s/(\(.*?\))/$class->_escape_for_iri_match($1)/eg;
34 5 return $xri;
35 }
36  
37 3 ▶sub _escape_for_iri_match {
Subroutine _escape_for_iri_match: called CC=1 SCAR=0.0
38 3 my ( $class, $matched ) = @_;
39 3 $matched =~ s/([\/\?\#])/URI::Escape::uri_escape_utf8($1)/eg;
40 3 return $matched;
41 }
42  
43 0 ▶sub to_url_normal {
Subroutine to_url_normal: not called CC=1 SCAR=6.9
Pod undocumented
44 0 my ( $class, $xri ) = @_;
45 0 return $class->iri_to_url( $class->to_iri_normal($xri) );
46 }
47  
48 0 ▶sub iri_to_url {
Subroutine iri_to_url: not called CC=1 SCAR=6.9
Pod undocumented
49 0 my ( $class, $iri ) = @_;
50 0 return $iri;
51 }
52  
53 0 ▶sub make_xri {
Subroutine make_xri: not called CC=2 SCAR=17.9
Pod undocumented
54 0 my ( $class, $xri ) = @_;
55 0 ▶ if ( $xri =~ /^xri:\/\// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xri =~ m[^xri://]) 0 0 0
56 0 $xri = sprintf q{xri://%s}, $xri;
57 }
58 0 return $xri;
59 }
60  
61 0 ▶sub root_authority {
Subroutine root_authority: not called CC=4 SCAR=30.0
Pod undocumented
62 0 my ( $class, $xri ) = @_;
63 0 ▶ $xri = substr($xri, 6) if (index($xri, q{xri://}) == 0);
Branch: 1 branch
BranchTrueFalseTotal
if index($xri, "xri://") == 0 0 0 0
64 0 my $authority = ( split( /\//, $xri, 2 ) )[0];
65  
66 0 my $root;
67 0 ▶ if ( $authority =~ /^(\([^\)]*\))/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($authority =~ /^(\([^\)]*\))/) { } 0 0 0
elsif ($authority =~ /^([\!\=\@\+\$\(])/) { } 0 0 0
68 0 $root = $1;
69 }
70 elsif ( $authority =~ /^([\!\=\@\+\$\(])/ ) {
71 0 $root = $1;
72 }
73 else {
74 0 $root = ( split /[!*]/, $authority )[0];
75 }
76 0 return $class->make_xri($root);
77 }
78  
79 0 ▶sub provider_is_authoritative {
Subroutine provider_is_authoritative: not called CC=4 SCAR=30.0
Pod undocumented
80 0 my ( $class, $provider_id, $canonical_id ) = @_;
81 0 ▶ return unless ($provider_id && $canonical_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $provider_id and $canonical_id 0 0 0
Condition0%0/3
$provider_id and $canonical_id
!ll&&!rl&&r
000
MC/DC0%0/2
$provider_id and $canonical_id
$provider_id $canonical_id
Truth table0%0/3
A and B
A= $provider_idB= $canonical_id
ABresult
0X0
100
111
82 0 my $lastbang = rindex($canonical_id, '!');
83 0 ▶ return 0 if $lastbang < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $lastbang < 0 0 0 0
84 0 my $parent = substr($canonical_id, 0, $lastbang);
85 0 return ( $parent eq $provider_id );
86 }
87  
88 3 1;
89  
« Lite/Message.pm ↑ Summary Lite/RelyingParty/Discover/Fetcher/Yadis.pm »