Deezer/Artist.pm

filter: Statementstmt 66.0% 37 / 56 Branchbran 50.0% 2 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 41.6% 5 / 12 Podpod 0.0% 0 / 6 totaltotal 59.0% 49 / 83 CC 4 SCAR 9.0
CC
4
Cov
67%
__ANON__
6.0
__ANON__
3.0
top
2.0
CRAP 2.5
« Deezer/Album.pm ↑ Summary Deezer/SearchResult.pm »
1 package WWW::Deezer::Artist;
2  
3 5 our $VERSION = '0.03';
4  
5 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 extends 'WWW::Deezer::Obj';
9  
10 5 ▶use WWW::Deezer;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use WWW::Deezer::Album;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # http://developers.deezer.com/api/artist
14  
15 5 has 'id', is => 'ro', isa => 'Int';
16 5 has 'name', is => 'ro', isa => 'Str';
17 5 has 'link', is => 'ro', isa => 'Str';
18 5 has 'tracklist', is => 'ro', isa => 'Str';
19 5 has 'share', is => 'ro', isa => 'Url';
20 5 has 'picture', is => 'ro', isa => 'Url';
21 5 has 'picture_small', is => 'ro', isa => 'Url';
22 5 has 'picture_medium', is => 'ro', isa => 'Url';
23 5 has 'picture_big', is => 'ro', isa => 'Url';
24 5 has 'picture_xl', is => 'ro', isa => 'Url';
25 5 has 'nb_album', is => 'rw', isa => 'Int';
26 5 has 'nb_fan', is => 'rw', isa => 'Int';
27  
28 5 has 'radio' => (
29 is => 'ro',
30 isa => 'JSONBoolean',
31 coerce => 1
32 );
33  
34 3 ▶around BUILDARGS => sub { # allow create Artist object with single argument passed to constructor - deezer ID
Subroutine __ANON__: called CC=3 SCAR=11.0
35 3 my ($orig, $class) = (shift, shift);
36 3 my $self = {};
37  
38 3 ▶ if (@_ == 1 && !ref $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and not ref $_[0]) { } 1 2 3
Condition100%3/3
@_ == 1 and not ref $_[0]
!ll&&!rl&&r
111
MC/DC100%2/2
@_ == 1 and not ref $_[0]
@_ == 1 not ref $_[0]
Truth table100%3/3
A and not(B)
A= @_ == 1B= not ref $_[0]
ABresult
0X0
100
111
39 1 $self = $class->$orig( id => $_[0] );
40 1 $self = WWW::Deezer->new->artist($_[0]);
41 }
42 else {
43 # 2DO: deal with Bool and JSON::XS::Boolean=\1 in 'radio' argument
44 2 $self = $class->$orig(@_);
45 }
46 3 return $self;
47 5 };
48  
49 0 ▶around [qw/nb_fan nb_album/] => sub { # add here another attributes which need fetching from server
Subroutine __ANON__: not called CC=2 SCAR=17.9
50 0 my ($orig, $self) = (shift, shift);
51 0 my $attr = $self->$orig(@_);
52  
53 0 ▶ unless (defined $attr) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $attr) 0 0 0
54 # fetch recreate artist.
55 0 my $new_obj = $self->deezer_obj->artist($self->id);
56 0 $attr= $new_obj->$orig(@_);
57 0 $self->reinit_attr_values($new_obj);
58 }
59  
60 0 return $attr;
61 5 };
62  
63 0 ▶sub top {
Subroutine top: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my $self = shift;
65 0 return;
66 }
67  
68 0 ▶sub albums {
Subroutine albums: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my $self = shift;
70 0 return;
71 }
72  
73 0 ▶sub comments {
Subroutine comments: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my $self = shift;
75 0 return;
76 }
77  
78 0 ▶sub fans {
Subroutine fans: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my $self = shift;
80 0 return;
81 }
82  
83 0 ▶sub related {
Subroutine related: not called CC=1 SCAR=6.9
Pod undocumented
84 0 my $self = shift;
85 0 return;
86 }
87  
88 0 ▶sub get_radio {
Subroutine get_radio: not called CC=1 SCAR=6.9
Pod undocumented
89 0 my $self = shift;
90 0 return;
91 }
92  
93 5 1;
« Deezer/Album.pm ↑ Summary Deezer/SearchResult.pm »