Com/Object.pm

filter: Statementstmt 91.4% 32 / 35 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 3 totaltotal 73.0% 46 / 63 CC 7 SCAR 11.1
CC
7
Cov
82%
get_language_handle
4.2
new
4.1
update
2.0
CRAP 3.0
« Com/DateTime.pm ↑ Summary Com/Units.pm »
1 package Weather::Com::Object;
2  
3 6 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #--------------------------------------------------------------------
9 # Define some globals
10 #--------------------------------------------------------------------
11 6 our $VERSION = sprintf "%d.%03d", q$Revision: 1.3 $ =~ /(\d+)/g;
12 6 my %LH = (); # our language handles
13  
14 #------------------------------------------------------------------------
15 # Constructor
16 #------------------------------------------------------------------------
17 7 ▶sub new {
Subroutine new: called CC=4 SCAR=14.1
Pod undocumented
18 7 my $proto = shift;
19 7 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
070
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
20 7 my $self = {};
21 7 my %parameters;
22  
23 # parameters provided by new method
24 7 ▶ if ( ref( $_[0] ) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 7 0 7
25 7 %parameters = %{ $_[0] };
26 } else {
27 0 %parameters = @_;
28 }
29  
30 7 $self = bless( $self, $class );
31  
32 # creating the SUPER instance
33 7 $self->{ARGS} = \%parameters;
34 7 ▶ if ( $parameters{lang} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parameters{'lang'}) { } 2 5 7
35 2 $self->{LANGUAGE} = $parameters{lang};
36 } else {
37 5 $self->{LANGUAGE} = 'en_US';
38 }
39  
40
41 7 return $self;
42 } # end new()
43  
44 #------------------------------------------------------------------------
45 # update barometric data
46 #------------------------------------------------------------------------
47 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
Pod undocumented
48 0 my $self = shift;
49 0 return 1;
50 }
51  
52 #------------------------------------------------------------------------
53 # Get a language handle
54 #------------------------------------------------------------------------
55 14 ▶sub get_language_handle {
Subroutine get_language_handle: called CC=4 SCAR=14.5
Pod undocumented
56 14 my $self = shift;
57 14 ▶ my $lang = shift || $self->{LANGUAGE};
Condition33%1/3
shift() || $self->{'LANGUAGE'}
l!l&&r!l&&!r
0140
MC/DC0%0/2
shift() || $self->{'LANGUAGE'}
shift() $self->{'LANGUAGE'}
Truth table33%1/3
A || B
A= shift()B= $self->{'LANGUAGE'}
ABresult
1X1
011
000
58
59 # check if we already have an open handle
60 14 ▶ unless (defined($LH{$lang})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $LH{$lang}) 4 10 14
61 4 ▶ $LH{$lang} = Weather::Com::L10N->get_handle($lang)
Branch: 1 branch
BranchTrueFalseTotal
$LH{$lang} = "Weather::Com::L10N"->get_handle($lang) or croak("Language?") 4 0 4
62 or croak ("Language?");
63 }
64
65 # return language handle
66 14 return $LH{$lang};
67 }
68  
69  
70 6 1;
« Com/DateTime.pm ↑ Summary Com/Units.pm »