GX/Route.pm

filter: Statementstmt 84.6% 33 / 39 Branchbran 90.0% 18 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 5 totaltotal 75.3% 55 / 73 CC 11 SCAR 19.6
CC
11
Cov
86%
_construct_uri
11.0
action
2.0
construct_path
2.0
CRAP 7.1
« GX/HTTP/Parser/Body/MultiPart.pm ↑ Summary GX/HTTP/Parameters.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/Route.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::Route;
7  
8 25 ▶use GX::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 25 ▶use GX::Route::Match;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 # ----------------------------------------------------------------------------------------------------------------------
13 # Class setup
14 # ----------------------------------------------------------------------------------------------------------------------
15  
16 25 ▶use GX::Class::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 25 build;
19  
20  
21 # ----------------------------------------------------------------------------------------------------------------------
22 # Public methods
23 # ----------------------------------------------------------------------------------------------------------------------
24  
25 0 ▶sub action {
Subroutine action: not called CC=1 SCAR=6.9
Pod undocumented
26  
27 0 complain "Abstract method";
28  
29 }
30  
31 0 ▶sub construct_path {
Subroutine construct_path: not called CC=1 SCAR=6.9
Pod undocumented
32  
33 0 complain "Abstract method";
34  
35 }
36  
37 0 ▶sub construct_uri {
Subroutine construct_uri: not called CC=1 SCAR=6.9
Pod undocumented
38  
39 0 complain "Abstract method";
40  
41 }
42  
43 0 ▶sub is_reversible {
Subroutine is_reversible: not called CC=1 SCAR=6.9
Pod undocumented
44  
45 0 complain "Abstract method";
46  
47 }
48  
49 0 ▶sub match {
Subroutine match: not called CC=1 SCAR=6.9
Pod undocumented
50  
51 0 complain "Abstract method";
52  
53 }
54  
55  
56 # ----------------------------------------------------------------------------------------------------------------------
57 # Private methods
58 # ----------------------------------------------------------------------------------------------------------------------
59  
60 47 ▶sub _construct_uri {
Subroutine _construct_uri: called CC=11 SCAR=24.0
61  
62 47 my $self = shift;
63 47 my %args = @_;
64  
65 47 my $uri;
66  
67 47 ▶ if ( ! defined $args{'scheme'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"scheme"}) 34 13 47
68 34 $args{'scheme'} = 'http';
69 }
70  
71 47 $uri = $args{'scheme'} . '://';
72  
73 47 ▶ if ( defined $args{'host'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{'host'}) { } 45 2 47
74 45 $uri .= $args{'host'};
75 }
76 else {
77 2 throw "No host specified";
78 }
79  
80 45 ▶ if ( defined $args{'port'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"port"}) 10 35 45
81  
82 10 ▶ if ( $args{'scheme'} eq 'http' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args{'scheme'} eq 'http') { } 6 4 10
elsif ($args{'scheme'} eq 'https') { } 4 0 4
83  
84 6 ▶ if ( $args{'port'} != 80 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"port"} != 80) 2 4 6
85 2 $uri .= ':' . $args{'port'};
86 }
87  
88 }
89 elsif ( $args{'scheme'} eq 'https' ) {
90  
91 4 ▶ if ( $args{'port'} != 443 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"port"} != 443) 2 2 4
92 2 $uri .= ':' . $args{'port'};
93 }
94  
95 }
96  
97 }
98  
99 45 ▶ if ( defined $args{'path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{'path'}) { } 45 0 45
100 45 $uri .= $args{'path'};
101 }
102 else {
103 0 throw "No path specified";
104 }
105  
106 45 ▶ if ( defined $args{'query'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"query"}) 4 41 45
107 4 $uri .= '?' . $args{'query'};
108 }
109  
110 45 ▶ if ( defined $args{'fragment'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"fragment"}) 2 43 45
111 2 $uri .= '#' . $args{'fragment'};
112 }
113  
114 45 return $uri;
115  
116 }
117  
118  
119 25 1;
120  
121 __END__
« GX/HTTP/Parser/Body/MultiPart.pm ↑ Summary GX/HTTP/Parameters.pm »