| 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
MC/DC100%1/1
$opts->{"clone"} // 0
$opts->{"clone"}
Truth table100%2/2
A
A= $opts->{"clone"}
| |||||||||||||
| 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
| |||||||||||||
| 15 | 4 | my $hash = $self->{hash}; | |||||||||||
| 16 | 4 | ▶ | return $hash->{$keys[0]} if @keys == 1; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 35 | 2 | $self->{hash} = $hash; | |||||||||||
| 36 | 2 | return $self; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 2 | 1; | |||||||||||