blib/lib/vCard.pm

filter: Statementstmt 96.3% 131 / 136 Branchbran 73.8% 31 / 42 Conditioncond 59.5% 28 / 47 MC/DCmcdc 20.0% 5 / 25 Subroutinesub 94.7% 36 / 38 Podpod 95.0% 19 / 20 totaltotal 81.1% 250 / 308 CC 50 SCAR 20.1
CC
50
Cov
84%
_build_address_nodes
23.4
_build_phone_nodes
8.8
_build_email_address_nodes
8.8
CRAP 7.4
« lib/Text/vCard/Node.pm ↑ Summary lib/Text/vCard.pm »
1 package vCard;
2 3 $vCard::VERSION = '3.09';
3 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Text::vCard;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use vCard::AddressBook;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 vCard - Read, write, and edit vCards
14  
15 =head1 SYNOPSIS
16  
17 use vCard;
18  
19 # create the object
20 my $vcard = vCard->new;
21  
22 # these methods load vCard data
23 # (see method documentation for details)
24 $vcard->load_file($filename);
25 $vcard->load_string($string);
26 $vcard->load_hashref($hashref);
27  
28 # simple getters/setters
29 $vcard->full_name('Bruce Banner, PhD');
30 $vcard->title('Research Scientist');
31 $vcard->photo('http://example.com/bbanner.gif');
32  
33 # complex getters/setters
34 $vcard->phones([
35 { type => ['work', 'text'], number => '651-290-1234', preferred => 1 },
36 { type => ['home'], number => '651-290-1111' }
37 ]);
38 $vcard->email_addresses([
39 { type => ['work'], address => 'bbanner@ssh.secret.army.mil' },
40 { type => ['home'], address => 'bbanner@timewarner.com' },
41 ]);
42  
43 # these methods output data in vCard format
44 my $file = $vcard->as_file($filename); # writes to $filename
45 my $string = $vcard->as_string; # returns a string
46  
47  
48 =head1 DESCRIPTION
49  
50 A vCard is a digital business card. vCard and L<vCard::AddressBook> provide an
51 API for parsing, editing, and creating vCards.
52  
53 This module is built on top of L<Text::vCard>. It provides a more intuitive user
54 interface.
55  
56 To handle an address book with several vCard entries in it, start with
57 L<vCard::AddressBook> and then come back to this module.
58  
59 Note that the vCard RFC requires version() and full_name(). This module does
60 not check or warn if these conditions have not been met.
61  
62  
63 =head1 ENCODING AND UTF-8
64  
65 See the 'ENCODING AND UTF-8' section of L<vCard::AddressBook>.
66  
67  
68 =head1 METHODS
69  
70 =cut
71  
72 6 ▶has encoding_in => ( is => 'rw', default => sub {'UTF-8'} );
Subroutine __ANON__: called CC=1 SCAR=0.0
73 6 ▶has encoding_out => ( is => 'rw', default => sub {'UTF-8'} );
Subroutine __ANON__: called CC=1 SCAR=0.0
74 15 ▶has _data => ( is => 'rw', default => sub { { version => '4.0' } } );
Subroutine __ANON__: called CC=1 SCAR=0.0
75  
76 3 with 'vCard::Role::FileIO';
77  
78 =head2 load_hashref($hashref)
79  
80 $hashref should look like this:
81  
82 full_name => 'Bruce Banner, PhD',
83 given_names => ['Bruce'],
84 family_names => ['Banner'],
85 title => 'Research Scientist',
86 photo => 'http://example.com/bbanner.gif',
87 phones => [
88 { type => ['work'], number => '651-290-1234', preferred => 1 },
89 { type => ['cell'], number => '651-290-1111' },
90 },
91 addresses => [
92 { type => ['work'], ... },
93 { type => ['home'], ... },
94 ],
95 email_addresses => [
96 { type => ['work'], address => 'bbanner@shh.secret.army.mil' },
97 { type => ['home'], address => 'bbanner@timewarner.com' },
98 ],
99  
100 Returns $self in case you feel like chaining.
101  
102 =cut
103  
104 1 ▶sub load_hashref {
Subroutine load_hashref: called CC=3 SCAR=11.3
Pod documented
105 1 my ( $self, $hashref ) = @_;
106 1 $self->_data($hashref);
107  
108 $self->_data->{version} = '4.0'
109 1 ▶ unless $self->_data->{version};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_data->{"version"} 1 0 1
110  
111 $self->_data->{photo} = URI->new( $self->_data->{photo} )
112 1 ▶ unless ref $self->_data->{photo} =~ /^URI/;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->_data->{"photo"} =~ /^URI/ 1 0 1
113  
114 1 return $self;
115 }
116  
117 =head2 load_file($filename)
118  
119 Returns $self in case you feel like chaining.
120  
121 =cut
122  
123 2 ▶sub load_file {
Subroutine load_file: called CC=1 SCAR=0.0
Pod documented
124 2 my ( $self, $filename ) = @_;
125  
126 2 my $addressBook = vCard::AddressBook->new({
127 encoding_in => $self->encoding_in,
128 encoding_out => $self->encoding_out,
129 });
130 2 my $vcard = $addressBook->load_file($filename)->vcards->[0];
131  
132 2 $self->_data($vcard->_data);
133  
134 2 return $self;
135 }
136  
137 =head2 load_string($string)
138  
139 Returns $self in case you feel like chaining. This method assumes $string is
140 decoded (but not MIME decoded).
141  
142 =cut
143  
144 3 ▶sub load_string {
Subroutine load_string: called CC=1 SCAR=0.0
Pod documented
145 3 my ( $self, $string ) = @_;
146  
147 3 my $addressBook = vCard::AddressBook->new({
148 encoding_in => $self->encoding_in,
149 encoding_out => $self->encoding_out,
150 });
151 3 my $vcard = $addressBook->load_string($string)->vcards->[0];
152  
153 2 $self->_data($vcard->_data);
154  
155 2 return $self;
156 }
157  
158 =head2 as_string()
159  
160 Returns the vCard as a string.
161  
162 =cut
163  
164 7 ▶sub as_string {
Subroutine as_string: called CC=5 SCAR=16.1
Pod documented
165 7 my ($self) = @_;
166 7 my $vcard = Text::vCard->new( { encoding_out => $self->encoding_out } );
167  
168 7 my $phones = $self->_data->{phones};
169 7 my $addresses = $self->_data->{addresses};
170 7 my $email_addresses = $self->_data->{email_addresses};
171  
172 7 $self->_build_simple_nodes( $vcard, $self->_data );
173 7 $self->_build_name_node( $vcard, $self->_data );
174 7 ▶ $self->_build_org_node( $vcard, $self->_data->{org} ) if $self->_data->{org};
Branch: 1 branch
BranchTrueFalseTotal
if $self->_data->{"org"} 0 7 7
175 7 ▶ $self->_build_phone_nodes( $vcard, $phones ) if $phones;
Branch: 1 branch
BranchTrueFalseTotal
if $phones 4 3 7
176 7 ▶ $self->_build_address_nodes( $vcard, $addresses ) if $addresses;
Branch: 1 branch
BranchTrueFalseTotal
if $addresses 4 3 7
177 7 ▶ $self->_build_email_address_nodes( $vcard, $email_addresses )
Branch: 1 branch
BranchTrueFalseTotal
if $email_addresses 4 3 7
178 if $email_addresses;
179  
180 7 return $vcard->as_string;
181 }
182  
183 18 ▶sub _simple_node_types {
Subroutine _simple_node_types: called CC=1 SCAR=0.0
184 18 qw/full_name title photo birthday timezone version/;
185 #geo, too?
186 }
187  
188 7 ▶sub _build_simple_nodes {
Subroutine _build_simple_nodes: called CC=5 SCAR=16.1
189 7 my ( $self, $vcard, $data ) = @_;
190  
191 7 foreach my $node_type ( $self->_simple_node_types ) {
192 42 ▶ if ( $node_type eq 'full_name' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node_type eq 'full_name') { } 7 35 42
193 7 ▶ next unless $data->{full_name};
Branch: 1 branch
BranchTrueFalseTotal
unless $data->{"full_name"} 3 4 7
194 4 $vcard->fullname( $data->{full_name} );
195 } else {
196 35 ▶ next unless $data->{$node_type};
Branch: 1 branch
BranchTrueFalseTotal
unless $data->{$node_type} 12 23 35
197 23 $vcard->$node_type( $data->{$node_type} );
198 }
199 }
200 }
201  
202 28 ▶sub _build_complex_node {
Subroutine _build_complex_node: called CC=2 SCAR=7.1
203 28 my ( $self, $vcard, $node_type, $data ) = @_;
204 28 ▶ croak '$data must be HASHREF' unless ref $data eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" 0 28 28
205 28 $vcard->add_node( { node_type => $node_type, data => [ $data ] } );
206 }
207  
208 0 ▶sub _build_org_node {
Subroutine _build_org_node: not called CC=2 SCAR=17.9
209 0 my ( $self, $vcard, $data ) = @_;
210
211 0 ▶ my $value = join ';', @{ $data || [] };
Condition0%0/2
$data || []
l!l
00
MC/DC0%0/1
$data || []
$data
Truth table0%0/2
A
A= $data
Aresult
11
00
212 0 $self->_build_complex_node( $vcard, 'ORG', { value => $value } );
213 }
214  
215 7 ▶sub _build_name_node {
Subroutine _build_name_node: called CC=7 SCAR=19.5
216 7 my ( $self, $vcard, $data ) = @_;
217  
218 7 ▶ my $value = join ',', @{ $data->{family_names} || [] };
Condition100%2/2
$data->{'family_names'} || []
l!l
43
MC/DC100%1/1
$data->{'family_names'} || []
$data->{'family_names'}
Truth table100%2/2
A
A= $data->{'family_names'}
Aresult
11
00
219 7 ▶ $value .= ';' . join ',', @{ $data->{given_names} || [] };
Condition100%2/2
$data->{'given_names'} || []
l!l
43
MC/DC100%1/1
$data->{'given_names'} || []
$data->{'given_names'}
Truth table100%2/2
A
A= $data->{'given_names'}
Aresult
11
00
220 7 ▶ $value .= ';' . join ',', @{ $data->{other_names} || [] };
Condition100%2/2
$data->{'other_names'} || []
l!l
25
MC/DC100%1/1
$data->{'other_names'} || []
$data->{'other_names'}
Truth table100%2/2
A
A= $data->{'other_names'}
Aresult
11
00
221 7 ▶ $value .= ';' . join ',', @{ $data->{honorific_prefixes} || [] };
Condition100%2/2
$data->{'honorific_prefixes'} || []
l!l
43
MC/DC100%1/1
$data->{'honorific_prefixes'} || []
$data->{'honorific_prefixes'}
Truth table100%2/2
A
A= $data->{'honorific_prefixes'}
Aresult
11
00
222 7 ▶ $value .= ';' . join ',', @{ $data->{honorific_suffixes} || [] };
Condition100%2/2
$data->{'honorific_suffixes'} || []
l!l
43
MC/DC100%1/1
$data->{'honorific_suffixes'} || []
$data->{'honorific_suffixes'}
Truth table100%2/2
A
A= $data->{'honorific_suffixes'}
Aresult
11
00
223  
224  
225 7 ▶ $self->_build_complex_node( $vcard, 'N', { value => $value } )
Branch: 1 branch
BranchTrueFalseTotal
if $value ne ";;;;" 4 3 7
226 if $value ne ';;;;';
227 }
228  
229 4 ▶sub _build_phone_nodes {
Subroutine _build_phone_nodes: called CC=8 SCAR=21.7
230 4 my ( $self, $vcard, $phones ) = @_;
231  
232 4 foreach my $phone (@$phones) {
233  
234 # TODO: better error handling
235 8 ▶ croak "'number' attr missing from 'phones'" unless $phone->{number};
Branch: 1 branch
BranchTrueFalseTotal
unless $phone->{"number"} 0 8 8
236 croak "'type' attr in 'phones' should be an arrayref"
237 8 ▶ if ( $phone->{type} && ref( $phone->{type} ) ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if $phone->{"type"} and ref $phone->{"type"} ne "ARRAY" 0 8 8
Condition33%1/3
$phone->{"type"} and ref $phone->{"type"} ne "ARRAY"
!ll&&!rl&&r
080
MC/DC0%0/2
$phone->{"type"} and ref $phone->{"type"} ne "ARRAY"
$phone->{"type"} ref $phone->{"type"} ne "ARRAY"
Truth table33%1/3
A and B
A= $phone->{"type"}B= ref $phone->{"type"} ne "ARRAY"
ABresult
0X0
100
111
238  
239 8 ▶ my $type = $phone->{type} || [];
Condition50%1/2
$phone->{'type'} || []
l!l
80
MC/DC0%0/1
$phone->{'type'} || []
$phone->{'type'}
Truth table50%1/2
A
A= $phone->{'type'}
Aresult
11
00
240 8 my $preferred = $phone->{preferred};
241 8 my $number = $phone->{number};
242  
243 8 my $params = [];
244 8 push @$params, { type => $_ } foreach @$type;
245 8 ▶ push @$params, { pref => $preferred } if $preferred;
Branch: 1 branch
BranchTrueFalseTotal
if $preferred 4 4 8
246  
247 8 $self->_build_complex_node( $vcard, 'TEL', { params => $params, value => $number } );
248 }
249 }
250  
251 4 ▶sub _build_address_nodes {
Subroutine _build_address_nodes: called CC=14 SCAR=31.5
252 4 my ( $self, $vcard, $addresses ) = @_;
253  
254 4 foreach my $address (@$addresses) {
255  
256 croak "'type' attr in 'addresses' should be an arrayref"
257 8 ▶ if ( $address->{type} && ref( $address->{type} ) ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if $address->{"type"} and ref $address->{"type"} ne "ARRAY" 0 8 8
Condition33%1/3
$address->{"type"} and ref $address->{"type"} ne "ARRAY"
!ll&&!rl&&r
080
MC/DC0%0/2
$address->{"type"} and ref $address->{"type"} ne "ARRAY"
$address->{"type"} ref $address->{"type"} ne "ARRAY"
Truth table33%1/3
A and B
A= $address->{"type"}B= ref $address->{"type"} ne "ARRAY"
ABresult
0X0
100
111
258  
259 8 ▶ my $type = $address->{type} || [];
Condition50%1/2
$address->{'type'} || []
l!l
80
MC/DC0%0/1
$address->{'type'} || []
$address->{'type'}
Truth table50%1/2
A
A= $address->{'type'}
Aresult
11
00
260 8 my $preferred = $address->{preferred};
261  
262 8 my $params = [];
263 8 push @$params, { type => $_ } foreach @$type;
264 8 ▶ push @$params, { pref => $preferred } if $preferred;
Branch: 1 branch
BranchTrueFalseTotal
if $preferred 0 8 8
265  
266 my $value = join ';',
267 $address->{pobox} || '',
268 $address->{extended} || '',
269 $address->{street} || '',
270 $address->{city} || '',
271 $address->{region} || '',
272 $address->{post_code} || '',
273 8 ▶ $address->{country} || '';
Condition50%7/14
$address->{'pobox'} || ''
l!l
08
$address->{'extended'} || ''
l!l
08
$address->{'street'} || ''
l!l
80
$address->{'city'} || ''
l!l
80
$address->{'region'} || ''
l!l
80
$address->{'post_code'} || ''
l!l
80
$address->{'country'} || ''
l!l
80
MC/DC0%0/1
$address->{'pobox'} || ''
$address->{'pobox'}
MC/DC0%0/1
$address->{'extended'} || ''
$address->{'extended'}
MC/DC0%0/1
$address->{'street'} || ''
$address->{'street'}
MC/DC0%0/1
$address->{'city'} || ''
$address->{'city'}
MC/DC0%0/1
$address->{'region'} || ''
$address->{'region'}
MC/DC0%0/1
$address->{'post_code'} || ''
$address->{'post_code'}
MC/DC0%0/1
$address->{'country'} || ''
$address->{'country'}
Truth table50%1/2
A
A= $address->{'pobox'}
Aresult
11
00
Truth table50%1/2
A
A= $address->{'extended'}
Aresult
11
00
Truth table50%1/2
A
A= $address->{'street'}
Aresult
11
00
Truth table50%1/2
A
A= $address->{'city'}
Aresult
11
00
Truth table50%1/2
A
A= $address->{'region'}
Aresult
11
00
Truth table50%1/2
A
A= $address->{'post_code'}
Aresult
11
00
Truth table50%1/2
A
A= $address->{'country'}
Aresult
11
00
274  
275 8 $self->_build_complex_node( $vcard, 'ADR', { params => $params, value => $value } );
276 }
277 }
278  
279 4 ▶sub _build_email_address_nodes {
Subroutine _build_email_address_nodes: called CC=8 SCAR=21.7
280 4 my ( $self, $vcard, $email_addresses ) = @_;
281  
282 4 foreach my $email_address (@$email_addresses) {
283  
284 # TODO: better error handling
285 croak "'address' attr missing from 'email_addresses'"
286 8 ▶ unless $email_address->{address};
Branch: 1 branch
BranchTrueFalseTotal
unless $email_address->{"address"} 0 8 8
287 croak "'type' attr in 'email_addresses' should be an arrayref"
288 if ( $email_address->{type}
289 8 ▶ && ref( $email_address->{type} ) ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if $email_address->{"type"} and ref $email_address->{"type"} ne "ARRAY" 0 8 8
Condition33%1/3
$email_address->{"type"} and ref $email_address->{"type"} ne "ARRAY"
!ll&&!rl&&r
080
MC/DC0%0/2
$email_address->{"type"} and ref $email_address->{"type"} ne "ARRAY"
$email_address->{"type"} ref $email_address->{"type"} ne "ARRAY"
Truth table33%1/3
A and B
A= $email_address->{"type"}B= ref $email_address->{"type"} ne "ARRAY"
ABresult
0X0
100
111
290  
291 8 ▶ my $type = $email_address->{type} || [];
Condition50%1/2
$email_address->{'type'} || []
l!l
80
MC/DC0%0/1
$email_address->{'type'} || []
$email_address->{'type'}
Truth table50%1/2
A
A= $email_address->{'type'}
Aresult
11
00
292 8 my $preferred = $email_address->{preferred};
293  
294 8 my $params = [];
295 8 push @$params, { type => $_ } foreach @$type;
296 8 ▶ push @$params, { pref => $preferred } if $preferred;
Branch: 1 branch
BranchTrueFalseTotal
if $preferred 4 4 8
297  
298 # TODO: better error handling
299 8 my $value = $email_address->{address};
300  
301 8 $self->_build_complex_node( $vcard, 'EMAIL', { params => $params, value => $value } );
302 }
303 }
304  
305 =head2 as_file($filename)
306  
307 Write data in vCard format to $filename.
308  
309 Dies if not successful.
310  
311 =cut
312  
313 1 ▶sub as_file {
Subroutine as_file: called CC=1 SCAR=0.0
Pod documented
314 1 my ( $self, $filename ) = @_;
315 1 my $file = $self->_path($filename);
316 1 $file->spew( $self->_iomode_out, $self->as_string );
317 1 return $file;
318 }
319  
320 =head1 SIMPLE GETTERS/SETTERS
321  
322 These methods accept and return strings.
323  
324 =head2 version()
325  
326 Version number of the vcard. Defaults to '4.0'
327  
328 =head2 full_name()
329  
330 A person's entire name as they would like to see it displayed.
331  
332 =head2 title()
333  
334 A person's position or job.
335  
336 =head2 photo()
337  
338 This should be a link. Accepts a string or a URI object. This method
339 always returns a L<URI> object.
340  
341 TODO: handle binary images using the data uri schema
342  
343 =head2 birthday()
344  
345 =head2 timezone()
346  
347  
348 =head1 COMPLEX GETTERS/SETTERS
349  
350 These methods accept and return array references rather than simple strings.
351  
352 =head2 family_names()
353  
354 Accepts/returns an arrayref of family names (aka surnames).
355  
356 =head2 given_names()
357  
358 Accepts/returns an arrayref.
359  
360 =head2 other_names()
361  
362 Accepts/returns an arrayref of names which don't qualify as family_names or
363 given_names.
364  
365 =head2 honorific_prefixes()
366  
367 Accepts/returns an arrayref. eg C<[ 'Dr.' ]>
368  
369 =head2 honorific_suffixes()
370  
371 Accepts/returns an arrayref. eg C<[ 'Jr.', 'MD' ]>
372  
373 =head2 phones()
374  
375 Accepts/returns an arrayref that looks like:
376  
377 [
378 { type => ['work'], number => '651-290-1234', preferred => 1 },
379 { type => ['cell'], number => '651-290-1111' },
380 ]
381  
382 =head2 addresses()
383  
384 Accepts/returns an arrayref that looks like:
385  
386 [
387 { type => ['work'], street => 'Main St', preferred => 0 },
388 { type => ['home'],
389 pobox => 1234,
390 extended => 'asdf',
391 street => 'Army St',
392 city => 'Desert Base',
393 region => '',
394 post_code => '',
395 country => 'USA',
396 preferred => 1,
397 },
398 ]
399  
400 =head2 email_addresses()
401  
402 Accepts/returns an arrayref that looks like:
403  
404 [
405 { type => ['work'], address => 'bbanner@ssh.secret.army.mil' },
406 { type => ['home'], address => 'bbanner@timewarner.com', preferred => 1 },
407 ]
408  
409 =cut
410  
411 11 ▶sub version { shift->_setget( 'version', @_ ) }
Subroutine version: called CC=1 SCAR=0.0
Pod documented
412 8 ▶sub full_name { shift->_setget( 'full_name', @_ ) }
Subroutine full_name: called CC=1 SCAR=0.0
Pod documented
413 8 ▶sub family_names { shift->_setget( 'family_names', @_ ) }
Subroutine family_names: called CC=1 SCAR=0.0
Pod documented
414 8 ▶sub given_names { shift->_setget( 'given_names', @_ ) }
Subroutine given_names: called CC=1 SCAR=0.0
Pod documented
415 7 ▶sub other_names { shift->_setget( 'other_names', @_ ) }
Subroutine other_names: called CC=1 SCAR=0.0
Pod documented
416 8 ▶sub honorific_prefixes { shift->_setget( 'honorific_prefixes', @_ ) }
Subroutine honorific_prefixes: called CC=1 SCAR=0.0
Pod documented
417 8 ▶sub honorific_suffixes { shift->_setget( 'honorific_suffixes', @_ ) }
Subroutine honorific_suffixes: called CC=1 SCAR=0.0
Pod documented
418 12 ▶sub title { shift->_setget( 'title', @_ ) }
Subroutine title: called CC=1 SCAR=0.0
Pod documented
419 24 ▶sub photo { shift->_setget( 'photo', @_ ) }
Subroutine photo: called CC=1 SCAR=0.0
Pod documented
420 12 ▶sub birthday { shift->_setget( 'birthday', @_ ) }
Subroutine birthday: called CC=1 SCAR=0.0
Pod documented
421 12 ▶sub timezone { shift->_setget( 'timezone', @_ ) }
Subroutine timezone: called CC=1 SCAR=0.0
Pod documented
422 8 ▶sub phones { shift->_setget( 'phones', @_ ) }
Subroutine phones: called CC=1 SCAR=0.0
Pod documented
423 8 ▶sub addresses { shift->_setget( 'addresses', @_ ) }
Subroutine addresses: called CC=1 SCAR=0.0
Pod documented
424 8 ▶sub email_addresses { shift->_setget( 'email_addresses', @_ ) }
Subroutine email_addresses: called CC=1 SCAR=0.0
Pod documented
425 0 ▶sub organization { shift->_setget( 'organization', @_ ) }
Subroutine organization: not called CC=1 SCAR=6.9
Pod undocumented
426  
427 142 ▶sub _setget {
Subroutine _setget: called CC=5 SCAR=16.2
428 142 my ( $self, $attr, $value ) = @_;
429  
430 142 ▶ $value = URI->new($value)
Branch: 1 branch
BranchTrueFalseTotal
if $value and $attr eq "photo" and ref $value =~ /^URI/ 0 142 142
Condition83%5/6
$value and $attr eq "photo" and ref $value =~ /^URI/
!ll&&!rl&&r
128140
$value and $attr eq "photo"
!ll&&!rl&&r
507814
MC/DC0%0/3
$value and $attr eq "photo" and ref $value =~ /^URI/
$value $attr eq "photo" ref $value =~ /^URI/
Truth table75%3/4
A and B and C
A= $valueB= $attr eq "photo"C= ref $value =~ /^URI/
ABCresult
0XX0
10X0
1100
1111
431 if $value && $attr eq 'photo' && ref $value =~ /^URI/;
432  
433 142 ▶ $self->_data->{$attr} = $value if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 92 50 142
434  
435 142 return $self->_data->{$attr};
436 }
437  
438 =head1 AUTHOR
439  
440 Eric Johnson (kablamo), github ~!at!~ iijo dot org
441  
442 =head1 ACKNOWLEDGEMENTS
443  
444 Thanks to L<Foxtons|http://foxtons.co.uk> for making this module possible by
445 donating a significant amount of developer time.
446  
447 =cut
448  
449 3 1;
« lib/Text/vCard/Node.pm ↑ Summary lib/Text/vCard.pm »