ZofCMS/Plugin/GoogleCalculator.pm

filter: Statementstmt 53.8% 14 / 26 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 37.5% 18 / 48 CC 7 SCAR 34.3
CC
7
Cov
36%
_do
56.0
_key
2.0
_defaults
2.0
CRAP 30.8
« ZofCMS/Plugin/JavaScriptMinifier.pm ↑ Summary ZofCMS/Plugin/RandomPasswordGeneratorPurePerl.pm »
1 package App::ZofCMS::Plugin::GoogleCalculator;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use WWW::Google::Calculator;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use base 'App::ZofCMS::Plugin::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub _key { 'plug_google_calculator' }
Subroutine _key: not called CC=1 SCAR=6.9
12 0 ▶sub _defaults {
Subroutine _defaults: not called CC=1 SCAR=6.9
13 0 from_query => 1,
14 expr => undef,
15 q_name => 'calc',
16 }
17 0 ▶sub _do {
Subroutine _do: not called CC=7 SCAR=40.3
18 0 my ( $self, $conf, $t, $q, $config ) = @_;
19  
20 $conf->{expr} = $conf->{expr}->( $t, $q, $config )
21 0 ▶ if ref $conf->{expr} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{"expr"} eq "CODE" 0 0 0
22  
23 my $v = $conf->{from_query}
24 ? $q->{ $conf->{q_name} }
25 0 ▶ : $conf->{expr};
Branch: 1 branch
BranchTrueFalseTotal
$conf->{'from_query'} ? : 0 0 0
26  
27 return
28 0 ▶ unless defined $v
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v and length $v 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
29 and length $v;
30  
31 0 my $calc = WWW::Google::Calculator->new;
32 0 my $result = $calc->calc( $v );
33  
34 0 ▶ if ( defined $result ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $result) { } 0 0 0
35 0 $t->{t}{plug_google_calculator} = $result;
36 }
37 else {
38 0 $t->{t}{plug_google_calculator_error} = $calc->error;
39  
40 $t->{t}{plug_google_calculator_error} = 'invalid input'
41 0 ▶ unless defined $t->{t}{plug_google_calculator_error};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $t->{"t"}{"plug_google_calculator_error"} 0 0 0
42 }
43 }
44  
45 1 1;
46 __END__
« ZofCMS/Plugin/JavaScriptMinifier.pm ↑ Summary ZofCMS/Plugin/RandomPasswordGeneratorPurePerl.pm »