Yath/Option/Bool.pm

filter: Statementstmt 86.1% 31 / 36 Branchbran 41.6% 5 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.1% 16 / 17 Podpod 0.0% 0 / 13 totaltotal 66.6% 52 / 78 CC 7 SCAR 15.4
CC
7
Cov
75%
get_env_value
20.0
get_default_value
3.0
is_populated
2.0
CRAP 4.7
« Yath/Option/BoolMap.pm ↑ Summary Yath/Option/Map.pm »
1 package Getopt::Yath::Option::Bool;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '2.000008';
6  
7 1 ▶use parent 'Getopt::Yath::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Getopt::Yath::HashBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶sub allows_shortval { 0 }
Subroutine allows_shortval: called CC=1 SCAR=0.0
Pod undocumented
11 1 ▶sub allows_default { 1 }
Subroutine allows_default: called CC=1 SCAR=0.0
Pod undocumented
12 9 ▶sub allows_arg { 0 }
Subroutine allows_arg: called CC=1 SCAR=0.0
Pod undocumented
13 6 ▶sub requires_arg { 0 }
Subroutine requires_arg: called CC=1 SCAR=0.0
Pod undocumented
14 6 ▶sub allows_autofill { 0 }
Subroutine allows_autofill: called CC=1 SCAR=0.0
Pod undocumented
15 4 ▶sub requires_autofill { 0 }
Subroutine requires_autofill: called CC=1 SCAR=0.0
Pod undocumented
16  
17 6 ▶sub no_arg_value { 1 } # --bool
Subroutine no_arg_value: called CC=1 SCAR=0.0
Pod undocumented
18  
19 # undef is not populated, otherwise qw have 1 or 0
20 162 ▶sub is_populated { defined(${$_[1]}) ? 1 : 0 }
Subroutine is_populated: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined ${$_[1];} ? : 6 156 162
21  
22 337 ▶sub add_value { ${$_[1]} = $_[2] }
Subroutine add_value: called CC=1 SCAR=0.0
Pod undocumented
23 3 ▶sub clear_field { ${$_[1]} = 0 } # --no-bool
Subroutine clear_field: called CC=1 SCAR=0.0
Pod undocumented
24  
25 # Default to 0 unless otherwise specified
26 sub get_default_value {
27 156 ▶ my $self = shift;
Subroutine get_default_value: called CC=3 SCAR=11.1
Pod undocumented
28 156 ▶ return undef if $self->{+MAYBE};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"maybe"} 0 156 156
29 156 ▶ return $self->SUPER::get_default_value(@_) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::get_default_value(@_) ? : 54 102 156
30 }
31  
32 165 ▶sub can_set_env { 1 }
Subroutine can_set_env: called CC=1 SCAR=0.0
Pod undocumented
33  
34 sub get_env_value {
35 0 ▶ my $opt = shift;
Subroutine get_env_value: not called CC=4 SCAR=30.0
Pod undocumented
36 0 my ($var, $ref) = @_;
37  
38 0 ▶ my $b = $$ref ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$$ref ? : 0 0 0
39 0 ▶ return $b unless $var =~ m/^!/;
Branch: 1 branch
BranchTrueFalseTotal
unless $var =~ /^!/ 0 0 0
40 0 ▶ return $b ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$b ? : 0 0 0
41 }
42  
43 1 1;
44  
45 __END__
« Yath/Option/BoolMap.pm ↑ Summary Yath/Option/Map.pm »