betfair/Template.pm

filter: Statementstmt 24.1% 7 / 29 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 100% 2 / 2 totaltotal 24.4% 11 / 45 CC 8 SCAR 36.1
CC
8
Cov
18%
markup_data
56.0
populate
6.0
BEGIN
1.0
CRAP 36.9
↑ Summary betfair.pm »
1 package WWW::betfair::Template;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head2 populate
6  
7 Returns the XML message required for the betfair API
8  
9 =cut
10  
11 0 ▶sub populate {
Subroutine populate: not called CC=2 SCAR=17.9
Pod documented
12 0 my ($uri, $action, $params) = @_;
13  
14 #handle getAccountStatement betfair syntax exception
15 0 ▶ my $req = $action eq 'getAccountStatement' ? 'req' : 'request';
Branch: 1 branch
BranchTrueFalseTotal
$action eq 'getAccountStatement' ? : 0 0 0
16
17 0 my $templateHeader = qq~<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><$action xmlns="$uri"><$req>~;
18  
19 0 my $templateBody = '';
20 0 $templateBody .= markup_data(undef,$params);
21 0 my $templateFooter = "</$req></$action></soap:Body></soap:Envelope>";
22 0 return $templateHeader . $templateBody . $templateFooter;
23 }
24  
25 =head2 markup_data
26  
27 Recursive tagging subroutine for a Perl data structure
28  
29 =cut
30  
31 0 ▶sub markup_data {
Subroutine markup_data: not called CC=7 SCAR=40.3
Pod documented
32 0 my ($key, $data) = @_;
33 0 my $string = '';
34 0 ▶ if (ref($data) eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $data eq 'HASH') { } 0 0 0
elsif (ref $data eq 'ARRAY') { } 0 0 0
35 0 ▶ $string .= "<$key>" if $key;
Branch: 1 branch
BranchTrueFalseTotal
if $key 0 0 0
36 0 foreach (keys %{$data}) {
37 0 $string .= markup_data($_, $data->{$_});
38 }
39 0 ▶ $string .= "</$key>" if $key;
Branch: 1 branch
BranchTrueFalseTotal
if $key 0 0 0
40 0 return $string;
41 }
42 elsif (ref($data) eq 'ARRAY') {
43 0 my $string = '';
44 0 foreach (@{$data}) {
45 0 $string .= markup_data($key, $_);
46 }
47 0 return $string;
48 }
49 else {
50 0 return "<$key>$data</$key>";
51 }
52 }
53 2 1;
↑ Summary betfair.pm »