Easer/ConfigHash.pm

filter: Statementstmt 100% 31 / 31 Branchbran 90.0% 9 / 10 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 5 / 5 totaltotal 98.2% 57 / 58 CC 8 SCAR 7.6
CC
8
Cov
98%
config
3.0
new
3.0
config_hash
2.0
CRAP 2.1
« Easer/V2.pm ↑ Summary Easer.pm »
1 package App::Easer::ConfigHash;
2 2 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use experimental qw< signatures >;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 { our $VERSION = '2.016' }
6 2 ▶use Storable ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶sub new ($package, $hash, $opts = {}) {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
9 2 ▶ my $self = bless { clone => ($opts->{clone} // 0) }, $package;
Condition100%2/2
$opts->{"clone"} // 0
l!l
11
MC/DC100%1/1
$opts->{"clone"} // 0
$opts->{"clone"}
Truth table100%2/2
A
A= $opts->{"clone"}
Aresult
11
00
10 2 return $self->set_config_hash($hash);
11 }
12  
13 4 ▶sub config ($self, @keys) {
Subroutine config: called CC=3 SCAR=11.0
Pod documented
14 4 ▶ return unless @keys;
Branch: 1 branch
BranchTrueFalseTotal
unless @keys 0 4 4
15 4 my $hash = $self->{hash};
16 4 ▶ return $hash->{$keys[0]} if @keys == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @keys == 1 2 2 4
17 2 return $hash->@{@keys};
18 }
19  
20 6 ▶sub config_hash ($self) {
Subroutine config_hash: called CC=2 SCAR=6.9
Pod documented
21 6 my $hash = $self->{hash};
22 6 ▶ $hash = Storable::dclone($hash) if $self->{clone};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"clone"} 4 2 6
23 6 return $hash;
24 }
25  
26 4 ▶sub set_config ($self, $key, @value) {
Subroutine set_config: called CC=2 SCAR=6.9
Pod documented
27 4 my $hash = $self->{hash};
28 4 delete($hash->{$key});
29 4 ▶ $hash->{$key} = $value[0] if @value;
Branch: 1 branch
BranchTrueFalseTotal
if @value 2 2 4
30 4 return $self;
31 }
32  
33 2 ▶sub set_config_hash ($self, $hash) {
Subroutine set_config_hash: called CC=2 SCAR=6.9
Pod documented
34 2 ▶ $hash = Storable::dclone($hash) if $self->{clone};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"clone"} 1 1 2
35 2 $self->{hash} = $hash;
36 2 return $self;
37 }
38  
39 2 1;
« Easer/V2.pm ↑ Summary Easer.pm »