Marvel/Config.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 92.3% 36 / 39 CC 4 SCAR 5.5
CC
4
Cov
100%
_set_keys
3.0
_get_auth_key
2.0
BEGIN
1.0
CRAP 1.7
« Marvel/Entity.pm ↑ Summary Marvel/Config/File.pm »
1 package WWW::Marvel::Config;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # my $cfg = WWW::Marvel::Config->new({
7 # private_key => 'a1b2',
8 # public_key => 'c3d4',
9 # });
10 # $cfg->get_private_key(); # a1b2
11 # $cfg->get_public_key(); # c3d4
12  
13 3 my @KEYS = (qw/ private_key public_key /);
14  
15 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
16 2 my ($class, $args) = @_;
17  
18 2 my $self = bless {}, $class;
19 2 $self->_set_keys($args);
20  
21 2 return $self;
22 }
23  
24 3 ▶sub get_private_key { shift->_get_auth_key('private_key') }
Subroutine get_private_key: called CC=1 SCAR=0.0
Pod undocumented
25 3 ▶sub get_public_key { shift->_get_auth_key('public_key') }
Subroutine get_public_key: called CC=1 SCAR=0.0
Pod undocumented
26  
27 6 ▶sub _get_auth_key {
Subroutine _get_auth_key: called CC=2 SCAR=6.9
28 6 my ($self, $name) = @_;
29 6 ▶ croak "Unknown '$name' key" if !exists $self->{ $name };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$name} 2 4 6
30 4 $self->{ $name };
31 }
32  
33 3 ▶sub _set_keys {
Subroutine _set_keys: called CC=3 SCAR=11.0
34 3 my ($self, $hash) = @_;
35  
36 3 for my $k (@KEYS) {
37 6 ▶ next if !exists $hash->{ $k };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{$k} 2 4 6
38 4 $self->{ $k } = $hash->{ $k };
39 }
40 }
41  
42 3 1;
« Marvel/Entity.pm ↑ Summary Marvel/Config/File.pm »