| 1 | package CGI::BrowserDetect; | ||||||||||||||||||||
| 2 | 2 | ▶ | use 5.006; use strict; use warnings; our $VERSION = '1.02'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use base qw/HTTP::BrowserDetect/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 4 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 6 | 4 | my $pkg = shift; | |||||||||||||||||||
| 7 | 4 | my $count = scalar @_; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 4 | ▶ | my %args = $count == 2 | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 10 | ? (HTTP_USER_AGENT => shift, HTTP_ACCEPT_LANGUAGE => shift) | ||||||||||||||||||||
| 11 | : $count == 1 | ||||||||||||||||||||
| 12 | ? (HTTP_USER_AGENT => shift) | ||||||||||||||||||||
| 13 | : @_; | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 4 | my $self = $pkg->SUPER::new($args{HTTP_USER_AGENT}); | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 4 | ▶ | if ($args{HTTP_ACCEPT_LANGUAGE}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | 2 | $self->{accept_language} = $args{HTTP_ACCEPT_LANGUAGE}; | |||||||||||||||||||
| 19 | 2 | ($self->{_lang}, $self->{_cnty}) = $self->{accept_language} =~ /([a-z]{2})\-([A-Z]{2})/; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 4 | return $self; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 4 | ▶ | sub detect { | ||||||||||||||||||
|
Subroutine
detect: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 26 | 4 | my ($self, @want) = @_; | |||||||||||||||||||
| 27 | my %provide = map { | ||||||||||||||||||||
| 28 | 4 | ▶ | $self->$_ ? ( $_ => $self->$_ ) : () | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | } @want; | ||||||||||||||||||||
| 30 | 4 | ▶ | return wantarray ? %provide : \%provide; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 8 | ▶ | sub device_type { | ||||||||||||||||||
|
Subroutine
device_type: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 34 | 8 | my ($self) = @_; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 8 | ▶ | return $self->mobile | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 37 | ? 'mobile' | ||||||||||||||||||||
| 38 | : $self->tablet | ||||||||||||||||||||
| 39 | ? 'tablet' | ||||||||||||||||||||
| 40 | : 'computer'; | ||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 4 | ▶ | sub lang { language(@_); } # backward comp | ||||||||||||||||||
|
Subroutine
lang: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 11 | ▶ | sub language { | ||||||||||||||||||
|
Subroutine
language: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 46 | 11 | my ($self) = @_; | |||||||||||||||||||
| 47 | 11 | my $language = $self->SUPER::language(); | |||||||||||||||||||
| 48 | 11 | ▶ | return $language || $self->{_lang}; | ||||||||||||||||||
|
Condition100%3/3
$language || $self->{'_lang'}
MC/DC100%2/2
$language || $self->{'_lang'}
$language
$self->{'_lang'}
Truth table100%3/3
A || B
A= $languageB= $self->{'_lang'}
| |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 4 | ▶ | sub cnty { country(@_); } # backwards | ||||||||||||||||||
|
Subroutine
cnty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 11 | ▶ | sub country { | ||||||||||||||||||
|
Subroutine
country: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 54 | 11 | my ($self) = @_; | |||||||||||||||||||
| 55 | 11 | my $country = $self->SUPER::country(); | |||||||||||||||||||
| 56 | 11 | ▶ | return $country || $self->{_cnty}; | ||||||||||||||||||
|
Condition100%3/3
$country || $self->{'_cnty'}
MC/DC100%2/2
$country || $self->{'_cnty'}
$country
$self->{'_cnty'}
Truth table100%3/3
A || B
A= $countryB= $self->{'_cnty'}
| |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 2 | 1; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||