blib/lib/HTTP/MobileUserID.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 75 CC 9 SCAR 39.4
CC
9
Cov
0%
init
90.0
new
2.0
has_user_id
2.0
CRAP 51.5
1 package HTTP::MobileUserID;
2
3 use strict;
4 use warnings;
5 use base qw/Class::Data::Accessor/;
6 __PACKAGE__->mk_classaccessors(qw/agent user_id supported/);
7
8 our $VERSION = '0.02';
9
10 sub new {
11 my $proto = shift;
12 my $self = bless {} , ref $proto || $proto;
13 $self->init(@_);
14 return $self;
15 }
16
17 sub has_user_id { shift->user_id }
18 sub no_user_id { !shift->user_id }
19 sub unsupported { !shift->supported }
20
21 *id = \&user_id;
22
23 sub init {
24 my $self = shift;
25 my $agent = $self->agent(shift);
26 $self->supported(1);
27
28 if ( $agent->is_docomo ) {
29 $self->supported(0) if $agent->html_version && $agent->html_version <= 2.0;
30 return if $self->unsupported;
31 $self->user_id($agent->serial_number);
32 }
33 elsif ( $agent->is_softbank ) {
34 $self->supported(0) if $agent->is_type_c;
35 return if $self->unsupported;
36 my $user_id = $agent->get_header('x-jphone-uid') || 'NULL';
37 $self->user_id($user_id) if $user_id ne 'NULL';
38 }
39 elsif ( $agent->is_ezweb ) {
40 $self->user_id($agent->get_header('x-up-subno'));
41 }
42 else {
43 $self->supported(0);
44 }
45 }
46
47 1;
48
49 __END__