Songkick/Artist.pm

filter: Statementstmt 97.7% 43 / 44 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 95.0% 58 / 61 CC 6 SCAR 11.6
CC
6
Cov
94%
__ANON__
6.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« Songkick/Event.pm ↑ Summary Songkick/Types.pm »
1 =head1 NAME
2  
3 Net::Songkick::Artist - Models an artist in the Songkick API
4  
5 =cut
6  
7 package Net::Songkick::Artist;
8  
9 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 7 ▶use Net::Songkick::MusicBrainz;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶use Net::Songkick::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 coerce 'Net::Songkick::Artist',
19 from 'HashRef',
20 3 ▶ via { Net::Songkick::Artist->new($_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
21  
22 has $_ => (
23 is => 'ro',
24 isa => 'Str',
25 7 ) for qw[id displayName uri];
26  
27 7 has identifier => (
28 is => 'ro',
29 isa => 'ArrayRef[Net::Songkick::MusicBrainz]',
30 );
31  
32 7 has onTourUntil => (
33 is => 'ro',
34 isa => 'Net::Songkick::DateTime',
35 coerce => 1,
36 );
37  
38 4 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=6 SCAR=18.0
39 4 my $orig = shift;
40 4 my $class = shift;
41  
42 4 my %args;
43  
44 4 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 4 0 4
45 4 %args = %{$_[0]};
46 } else {
47 0 %args = @_;
48 }
49  
50 4 ▶ if (exists $args{identifier}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"identifier"}) 4 0 4
51 4 foreach (@{$args{identifier}}) {
52 4 ▶ if (ref $_ ne 'Net::Songkick::MusicBrainz') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ ne "Net::Songkick::MusicBrainz") 3 1 4
53 3 $_ = Net::Songkick::MusicBrainz->new($_);
54 }
55 }
56 }
57
58 4 ▶ if (exists $args{onTourUntil}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"onTourUntil"}) 1 3 4
59 1 $args{onTourUntil} = { date => $args{onTourUntil} };
60 }
61  
62
63 4 $class->$orig(\%args);
64 7 };
65  
66 7 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 7 __PACKAGE__->meta->make_immutable;
68  
69 =head1 AUTHOR
70  
71 Dave Cross <dave@perlhacks.com>
72  
73 =head1 SEE ALSO
74  
75 perl(1), L<http://www.songkick.com/>, L<http://developer.songkick.com/>
76  
77 =head1 COPYRIGHT AND LICENSE
78  
79 Copyright (C) 2010, Magnum Solutions Ltd. All Rights Reserved.
80  
81 This script is free software; you can redistribute it and/or modify it
82 under the same terms as Perl itself.
83  
84 =cut
85  
86 7 1;
« Songkick/Event.pm ↑ Summary Songkick/Types.pm »