UserAgent/Base/Accessors.pm

filter: Statementstmt 93.5% 58 / 62 Branchbran 50.0% 5 / 10 Conditioncond 40.0% 4 / 10 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 88.8% 16 / 18 Podpod 100% 2 / 2 totaltotal 80.3% 86 / 107 CC 13 SCAR 15.1
CC
13
Cov
82%
version
20.0
version
4.0
__ANON__
3.1
CRAP 4.5
« UserAgent/Base/IS.pm ↑ Summary UserAgent/Constants.pm »
1 package Parse::HTTP::UserAgent::Base::Accessors;
2 4 $Parse::HTTP::UserAgent::Base::Accessors::VERSION = '0.43';
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Parse::HTTP::UserAgent::Constants qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=11.0
8 4 my @simple = qw(
9 device
10 generic
11 lang
12 mobile
13 name
14 original_name
15 original_version
16 os
17 parser
18 robot
19 strength
20 tablet
21 touch
22 unknown
23 wap
24 );
25  
26 4 my @multi = qw(
27 mozilla
28 extras
29 dotnet
30 );
31  
32 4 ▶ no strict qw(refs); ## no critic (TestingAndDebugging::ProhibitNoStrict)
Subroutine BEGIN: called CC=1 SCAR=0.0
33 4 foreach my $name ( @simple ) {
34 60 my $id = 'UA_' . uc $name;
35 60 $id = __PACKAGE__->$id();
36 60 ▶ *{ $name } = sub { return shift->[$id] || q{} };
Subroutine __ANON__: called CC=2 SCAR=7.1
Condition50%1/2
+(shift())->[$id] || ''
l!l
90
MC/DC0%0/1
+(shift())->[$id] || ''
+(shift())->[$id]
Truth table50%1/2
A
A= +(shift())->[$id]
Aresult
11
00
37 }
38  
39 4 foreach my $name ( @multi ) {
40 12 my $id = 'UA_' . uc $name;
41 12 $id = __PACKAGE__->$id();
42 12 ▶ *{ $name } = sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
43 1 my $self = shift;
44 1 ▶ return +() if ! $self->[ $id ];
Branch: 1 branch
BranchTrueFalseTotal
unless $self->[$id] 0 1 1
45 1 my @rv = @{ $self->[ $id ] };
46 1 ▶ return wantarray ? @rv : $rv[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
47 12 };
48 }
49 }
50  
51 2 ▶sub version {
Subroutine version: called CC=4 SCAR=13.9
Pod documented
52 2 my $self = shift;
53 2 ▶ my $type = shift || q{};
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
54 2 ▶ return $self->[ $type eq 'raw' ? UA_VERSION_RAW : UA_VERSION ] || 0;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'raw' ? : 1 1 2
Condition50%1/2
$$self[$type eq 'raw' ? 26 : 26] || 0
l!l
20
MC/DC0%0/1
$$self[$type eq 'raw' ? 26 : 26] || 0
$$self[$type eq 'raw' ? 26 : 26]
Truth table50%1/2
A
A= $$self[$type eq 'raw' ? 26 : 26]
Aresult
11
00
55 }
56  
57 1 ▶sub toolkit {
Subroutine toolkit: called CC=1 SCAR=0.0
Pod documented
58 1 my $self = shift;
59 1 return Parse::HTTP::UserAgent::Base::Accessors::toolkit->new(
60 $self->[UA_TOOLKIT]
61 );
62 }
63  
64 package
65 Parse::HTTP::UserAgent::Base::Accessors::toolkit;
66 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 4 ▶use overload '""', => 'name',
Subroutine BEGIN: called CC=1 SCAR=0.0
69 '0+', => 'version',
70 fallback => 1,
71 4 ;
72 4 ▶use constant ID_NAME => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 4 ▶use constant ID_VERSION_RAW => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 4 ▶use constant ID_VERSION => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
77 1 my($class, $tk) = @_;
78 1 ▶ return bless [ $tk ? @{ $tk } : (undef) x 3 ], $class;
Branch: 1 branch
BranchTrueFalseTotal
$tk ? : 1 0 1
79 }
80  
81 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
82 0 return shift->[ID_NAME];
83 }
84  
85 0 ▶sub version {
Subroutine version: not called CC=4 SCAR=30.0
86 0 my $self = shift;
87 0 ▶ my $type = shift || q{};
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
88 0 ▶ return $self->[ $type eq 'raw' ? ID_VERSION_RAW : ID_VERSION ] || 0;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'raw' ? : 0 0 0
Condition0%0/2
$$self[$type eq 'raw' ? 1 : 2] || 0
l!l
00
MC/DC0%0/1
$$self[$type eq 'raw' ? 1 : 2] || 0
$$self[$type eq 'raw' ? 1 : 2]
Truth table0%0/2
A
A= $$self[$type eq 'raw' ? 1 : 2]
Aresult
11
00
89 }
90  
91 4 1;
92  
93 __END__
« UserAgent/Base/IS.pm ↑ Summary UserAgent/Constants.pm »