Yath/Settings/Group.pm

filter: Statementstmt 48.9% 23 / 47 Branchbran 18.7% 3 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 46.1% 6 / 13 Podpod 77.7% 7 / 9 totaltotal 44.4% 40 / 90 CC 10 SCAR 17.9
CC
10
Cov
41%
option
20.0
check_option
6.0
AUTOLOAD
4.1
CRAP 6.0
« Yath/HashBase.pm ↑ Summary Yath/Settings.pm »
1 package Getopt::Yath::Settings::Group;
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 Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new {
10 62 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
11 62 ▶ my $self = (@_ != 1) ? { @_ } : $_[0];
Branch: 1 branch
BranchTrueFalseTotal
@_ != 1 ? : 62 0 62
12  
13 62 return bless($self, $class);
14 }
15  
16 0 ▶sub all { return %{$_[0]} }
Subroutine all: not called CC=1 SCAR=6.9
Pod documented
17  
18 0 ▶sub check_option { exists($_[0]->{$_[1]}) ? 1 : 0 }
Subroutine check_option: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[0]{$_[1]} ? : 0 0 0
19  
20 sub option :lvalue {
21 0 ▶ my $self = shift;
Subroutine option: not called CC=4 SCAR=30.0
Pod documented
22 0 my ($option, @vals) = @_;
23  
24 0 ▶ Carp::confess("Too many arguments for option()") if @vals > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @vals > 1 0 0 0
25 0 ▶ Carp::confess("The '$option' option does not exist") unless exists $self->{$option};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$option} 0 0 0
26  
27 0 ▶ ($self->{$option}) = @vals if @vals;
Branch: 1 branch
BranchTrueFalseTotal
if @vals 0 0 0
28  
29 0 return $self->{$option};
30 }
31  
32 sub create_option {
33 0 ▶ my $self = shift;
Subroutine create_option: not called CC=1 SCAR=6.9
Pod documented
34 0 my ($name, $val) = @_;
35  
36 0 $self->{$name} = $val;
37  
38 0 return $self->{$name};
39 }
40  
41 sub option_ref {
42 1426 ▶ my $self = shift;
Subroutine option_ref: called CC=3 SCAR=12.0
Pod documented
43 1426 my ($name, $create) = @_;
44  
45 1426 ▶ Carp::confess("The '$name' option does not exist") unless $create || exists $self->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $create or exists $self->{$name} 0 1426 1426
Condition33%1/3
$create or exists $self->{$name}
l!l&&r!l&&!r
142600
MC/DC0%0/2
$create or exists $self->{$name}
$create exists $self->{$name}
Truth table33%1/3
A or B
A= $createB= exists $self->{$name}
ABresult
1X1
011
000
46  
47 1426 return \($self->{$name});
48 }
49  
50 sub delete_option {
51 0 ▶ my $self = shift;
Subroutine delete_option: not called CC=1 SCAR=6.9
Pod documented
52 0 my ($name) = @_;
53  
54 0 delete $self->{$name};
55 }
56  
57 sub remove_option {
58 0 ▶ my $self = shift;
Subroutine remove_option: not called CC=1 SCAR=6.9
Pod documented
59 0 my ($name) = @_;
60 0 delete ${$self}->{$name};
61 }
62  
63 1 our $AUTOLOAD;
64 sub AUTOLOAD : lvalue {
65 62 ▶ my $this = shift;
Subroutine AUTOLOAD: called CC=3 SCAR=14.2
66  
67 62 my $option = $AUTOLOAD;
68 62 $option =~ s/^.*:://g;
69  
70 62 ▶ return if $option eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $option eq "DESTROY" 62 0 62
71  
72 0 ▶ Carp::confess("Method $option() must be called on a blessed instance") unless ref($this);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
73  
74 0 $this->option($option, @_);
75 }
76  
77 sub TO_JSON {
78 0 ▶ my $self = shift;
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod undocumented
79 0 return {%$self};
80 }
81  
82 1 1;
83  
84 __END__
« Yath/HashBase.pm ↑ Summary Yath/Settings.pm »