blib/lib/MMS/Mail/Message/Parsed.pm

filter: Statementstmt 53.0% 26 / 49 Branchbran 16.6% 2 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 4 / 4 totaltotal 52.0% 38 / 73 CC 8 SCAR 19.4
CC
8
Cov
46%
retrieve_attachments
14.4
add_image
6.0
add_video
6.0
CRAP 6.9
↑ Summary
1 package MMS::Mail::Message::Parsed;
2  
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use base 'MMS::Mail::Message';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 MMS::Mail::Message::Parsed - A class representing a parsed MMS (or picture) message, that has been parsed by an MMS::Mail::Provider class.
11  
12 =head1 VERSION
13  
14 Version 0.06
15  
16 =cut
17  
18 4 our $VERSION = '0.06';
19  
20 =head1 SYNOPSIS
21  
22 This class is used by MMS::Mail::Parser to provide a final data storage class after the MMS has been parsed by the MMS::Mail::Provider class. It inherits from the MMS::Mail::Message class and extends it's methods to allow access to parsed properties.
23  
24 =head1 METHODS
25  
26 The MMS::Mail::Message::Parsed class inherits all the methods from it's parent class MMS::Mail::Message.
27  
28 =head2 Constructor
29  
30 =over
31  
32 =item C<new()>
33  
34 Return a new MMS::Mail::Message::Parsed object.
35  
36 =back
37  
38 =head2 Regular Methods
39  
40 =over
41  
42 =item C<add_image> MIME::Entity
43  
44 Instance method - Adds the supplied MIME::Entity attachment to the image stack for the message. This method is mainly used by the MMS::Mail::Provider class to add images while parsing.
45  
46 =item C<add_video> MIME::Entity
47  
48 Instance method - Adds the supplied MIME::Entity attachment to the video stack for the message. This method is mainly used by the MMS::Mail::Provider class to add videos while parsing.
49  
50 =item C<images>
51  
52 Instance method - Returns an array reference to an array of images from the message.
53  
54 =item C<videos>
55  
56 Instance method - Returns an array reference to an array of videos from the message.
57  
58 =item C<phone_number> STRING
59  
60 Instance method - Returns the MMS mobile number the message was sent from when invoked with no supplied parameter. When supplied with a parameter it sets the object property to the supplied parameter. This property is not set by the MMS::Mail::Provider class but is set by it's subclasses.
61  
62 =item C<retrieve_attachments> STRING
63  
64 Instance method - Expects a mime-type to be passed as an argument and a regular expression match using the supplied string is applied to each attachment in the attachment stack of the message object and a reference to an array of objects where the mime-type matches the supplied string is returned. In the event no attachment was matched to the supplied mime-type an undef value is returned.
65  
66 =back
67  
68 =head1 AUTHOR
69  
70 Rob Lee, C<< <robl at robl.co.uk> >>
71  
72 =head1 BUGS
73  
74 Please report any bugs or feature requests to
75 C<bug-mms-mail-message-parsed@rt.cpan.org>, or through the web interface at
76 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MMS-Mail-Message-Parsed>.
77 I will be notified, and then you'll automatically be notified of progress on
78 your bug as I make changes.
79  
80 =head1 NOTES
81  
82 Please read the Perl artistic license ('perldoc perlartistic') :
83  
84 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
85 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
86 OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
87  
88 =head1 ACKNOWLEDGEMENTS
89  
90 As per usual this module is sprinkled with a little Deb magic.
91  
92 =head1 COPYRIGHT & LICENSE
93  
94 Copyright 2005 Rob Lee, all rights reserved.
95  
96 This program is free software; you can redistribute it and/or modify it
97 under the same terms as Perl itself.
98  
99 =head1 SEE ALSO
100  
101 L<MMS::Mail::Message>, L<MMS::Mail::Message::Parsed>, L<MMS::Mail::Provider>
102  
103 =cut
104  
105 4 my @Accessors=( "phone_number",
106 "images",
107 "videos"
108 );
109  
110 # Class data retrieval
111 4 ▶sub _Accessors {
Subroutine _Accessors: called CC=1 SCAR=0.0
112 4 return \@Accessors;
113 }
114  
115 4 __PACKAGE__->mk_accessors(@{__PACKAGE__->_Accessors});
116  
117 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
118  
119 1 my $type = shift;
120  
121 1 my $self = {};
122 1 $self = SUPER::new $type( @_ );
123  
124 1 ▶ if (defined($self->{message})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"message"}) 0 1 1
125 0 $self->SUPER::_clone_data($self->{message});
126 }
127  
128 1 $self->{images} = [];
129 1 $self->{videos} = [];
130  
131 1 return $self;
132 }
133  
134 0 ▶sub add_image {
Subroutine add_image: not called CC=2 SCAR=17.9
Pod documented
135  
136 0 my $self = shift;
137 0 my $image = shift;
138  
139 0 ▶ unless (defined($image)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $image) 0 0 0
140 0 return 0;
141 }
142  
143 0 push @{$self->{images}}, $image;
144  
145 0 return 1;
146  
147 }
148  
149 0 ▶sub add_video {
Subroutine add_video: not called CC=2 SCAR=17.9
Pod documented
150  
151 0 my $self = shift;
152 0 my $video = shift;
153  
154 0 ▶ unless(defined $video) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $video) 0 0 0
155 0 return 0;
156 }
157  
158 0 push @{$self->{videos}}, $video;
159  
160 0 return 1;
161  
162 }
163  
164 1 ▶sub retrieve_attachments {
Subroutine retrieve_attachments: called CC=5 SCAR=26.7
Pod documented
165  
166 1 my $self = shift;
167 1 my $type = shift;
168  
169 1 ▶ unless (defined $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type) 1 0 1
170 1 return [];
171 }
172
173 0 my @mimeattachments;
174 0 foreach my $attachment (@{$self->attachments}) {
175 0 ▶ if ($attachment->mime_type =~ /$type/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attachment->mime_type =~ /$type/) 0 0 0
176 0 push @mimeattachments, $attachment;
177 }
178 }
179  
180 0 ▶ if (@mimeattachments>0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@mimeattachments > 0) { } 0 0 0
181 0 return \@mimeattachments;
182 } else {
183 0 return [];
184 }
185  
186 }
187  
188 4 1; # End of MMS::Mail::Message::Parsed
↑ Summary