blib/lib/MMS/Mail/Provider/UKOrange.pm

filter: Statementstmt 45.1% 14 / 31 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 38.7% 19 / 49 CC 8 SCAR 38.8
CC
8
Cov
33%
parse
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 48.3
↑ Summary
1 package MMS::Mail::Provider::UKOrange;
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 base 'MMS::Mail::Provider';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use MMS::Mail::Message::Parsed;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 MMS::Mail::Provider::UKOrange - This provides a class for parsing an MMS::Mail::Message object that has been sent via the UK Orange network.
13  
14 =head1 VERSION
15  
16 Version 0.06
17  
18 =cut
19  
20 2 our $VERSION = '0.06';
21  
22 =head1 SYNOPSIS
23  
24 This class provides a parse method for parsing an MMS::Mail::Message object into an MMS::Mail::Message::Parsed object for MMS messages sent from the UK Orange network.
25  
26 =head1 METHODS
27  
28 The following are the top-level methods of the MMS::Mail::Parser::0range class.
29  
30 =head2 Constructor
31  
32 =over
33  
34 =item C<new()>
35  
36 Return a new MMS::Mail::Provider::0range object.
37  
38 =back
39  
40 =head2 Regular Methods
41  
42 =over
43  
44 =item C<parse> MMS::Mail::Message
45  
46 The C<parse> method is called as an instance method. It parses the MMS::Mail::Message object and returns an MMS::Mail::Message::Parsed object.
47  
48 =back
49  
50 =head1 AUTHOR
51  
52 Rob Lee, C<< <robl at robl.co.uk> >>
53  
54 =head1 BUGS
55  
56 Please report any bugs or feature requests to
57 C<bug-mms-mail-provider-ukorange@rt.cpan.org>, or through the web interface at
58 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MMS-Mail-Provider-UKOrange>.
59 I will be notified, and then you'll automatically be notified of progress on
60 your bug as I make changes.
61  
62 =head1 NOTES
63  
64 Please read the Perl artistic license ('perldoc perlartistic') :
65  
66 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
67 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
68 OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
69  
70 =head1 ACKNOWLEDGEMENTS
71  
72 Thanks to Paul and Nige for the sample messages.
73  
74 As per usual this module is sprinkled with a little Deb magic.
75  
76 =head1 COPYRIGHT & LICENSE
77  
78 Copyright 2005 Rob Lee, all rights reserved.
79  
80 This program is free software; you can redistribute it and/or modify it
81 under the same terms as Perl itself.
82  
83 =head1 SEE ALSO
84  
85 L<MMS::Mail::Message>, L<MMS::Mail::Message::Parsed>, L<MMS::Mail::Provider>
86  
87  
88 =cut
89  
90 0 ▶sub parse {
Subroutine parse: not called CC=8 SCAR=42.8
Pod documented
91  
92 0 my $self = shift;
93 0 my $message = shift;
94  
95 0 ▶ unless (defined $message) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $message) 0 0 0
96 0 return undef;
97 }
98  
99 0 my $skiptext = "This Orange Multi Media Message was sent wirefree";
100  
101 0 my $parsed = new MMS::Mail::Message::Parsed(message=>$message);
102  
103 0 $parsed->header_subject($message->header_subject);
104  
105 0 foreach my $element (@{$parsed->attachments}) {
106 0 ▶ if ($element->mime_type eq 'text/plain') {
Branch: 3 branches
BranchTrueFalseTotal
if ($element->mime_type eq 'text/plain') { } 0 0 0
elsif ($element->mime_type =~ /jpeg$/) { } 0 0 0
elsif ($element->mime_type =~ /^video/) { } 0 0 0
107 0 ▶ if ($element->bodyhandle->as_string ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($element->bodyhandle->as_string ne "") 0 0 0
108 0 ▶ if ($element->bodyhandle->as_string !~ /$skiptext/m) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($element->bodyhandle->as_string =~ /$skiptext/m) 0 0 0
109 0 $parsed->body_text($element->bodyhandle->as_string);
110 }
111 }
112 } elsif ($element->mime_type =~ /jpeg$/) {
113 0 $parsed->add_image($element);
114 } elsif ($element->mime_type =~ /^video/) {
115 0 $parsed->add_video($element);
116 }
117 }
118  
119 # Set mobile number property to a VALID number
120 0 $parsed->phone_number($self->retrieve_phone_number($parsed->header_from));
121 0 return $parsed;
122 }
123  
124  
125 2 1; # End of MMS::Mail::Provider::UKOrange
↑ Summary