RPC/Fault.pm

filter: Statementstmt 63.6% 14 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 65.6% 21 / 32 CC 1 SCAR 3.6
CC
1
Cov
64%
new
2.0
code
2.0
string
2.0
CRAP 1.4
« RPC/Request.pm ↑ Summary
1 package POE::Filter::XML::RPC::Fault;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use POE::Filter::XML::RPC::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use base('POE::Filter::XML::Node');
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.04';
11  
12 sub new()
13 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
14 0 my ($class, $code, $string) = @_;
15  
16 0 my $self = $class->SUPER::new('fault');
17  
18 0 my $hash = {'faultCode' => $code, 'faultString' => $string};
19 0 my $struct = POE::Filter::XML::RPC::Value->new($hash);
20  
21 0 $self->appendChild($struct);
22  
23 0 return bless($self, $class);
24 }
25  
26 sub code()
27 0 ▶{
Subroutine code: not called CC=1 SCAR=6.9
Pod documented
28 0 return shift(@_)->find('child::value/child::struct/child::member[child::name/child::text() = "faultCode"]/child::value/child::*[self::int or self::i4]/child::text()');
29 }
30  
31 sub string()
32 0 ▶{
Subroutine string: not called CC=1 SCAR=6.9
Pod documented
33 0 return shift(@_)->find('child::value/child::struct/child::member[child::name/child::text() = "faultString"]/child::value/child::string/child::text()');
34 }
35  
36 =pod
37  
38 =head1 NAME
39  
40 POE::Filter::XML::RPC::Fault - A XMLRPC Fault abstraction
41  
42 =head1 SYNOPSIS
43  
44 use 5.010;
45 use POE::Filter::XML::RPC::Fault;
46  
47 my $fault = POE::Filter::XML::RPC::Fault->new(503, 'Fail text here');
48  
49 say $fault->code(); # 503
50 say $fault->string(); # Fail text here
51  
52 =head1 DESCRIPTION
53  
54 POE::Filter::XML::RPC::Fault provides a convient object for representing faults
55 within XMLRPC without having to construct them manually.
56  
57 =head1 PUBLIC METHODS
58  
59 =over 4
60  
61 =item new()
62  
63 new() accepts two arguments, one, the integer code value for the fault, and
64 two, a string explaining the fault. Both arguments are required.
65  
66 =item code()
67  
68 code() returns the integer value for the particular Fault. Takes no arguments.
69  
70 =item string()
71  
72 string() returns the string value for the particular Fault. Takes no arguments.
73  
74 =back
75  
76 =head1 NOTES
77  
78 Fault is actually a subclass of POE::Filter::XML::Node and so all of its
79 methods, including XML::LibXML::Element's, are available for use. This could
80 ultimately be useful to avoid marshalling all of the data out of the Node and
81 instead apply an XPATH expression to target specifically what is desired deep
82 within a nested structure.
83  
84 =head1 AUTHOR
85  
86 Copyright 2009 Nicholas Perez.
87 Licensed and distributed under the GPL.
88  
89 =cut
90  
91 2 1;
« RPC/Request.pm ↑ Summary