Ref/Role/API.pm

filter: Statementstmt 100% 20 / 20 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 83.3% 30 / 36 CC 4 SCAR 8.8
CC
4
Cov
89%
compute
4.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« Ref/CLOCK/Base.pm ↑ Summary Ref/LRU.pm »
1 package Cache::Ref::Role::API;
2 7 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 $Cache::Ref::Role::API::AUTHORITY = 'cpan:NUFFIN';
4 }
5 7 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 $Cache::Ref::Role::API::VERSION = '0.05'; # TRIAL
7 }
8 7 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 7 requires qw(
15 get
16 set
17 remove
18 clear
19 hit
20 expire
21 );
22  
23 4 ▶sub compute {
Subroutine compute: called CC=4 SCAR=14.2
Pod undocumented
24 4 my ( $self, $key, $code ) = @_;
25  
26 4 ▶ croak "must specify key and code"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key and defined $code 0 4 4
Condition33%1/3
defined $key and defined $code
!ll&&!rl&&r
004
MC/DC0%0/2
defined $key and defined $code
defined $key defined $code
Truth table33%1/3
A and B
A= defined $keyB= defined $code
ABresult
0X0
100
111
27 unless defined($key) && defined($code);
28  
29 4 ▶ if ( defined( my $cached = $self->get($key) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $cached = $self->get($key))) { } 2 2 4
30 2 return $cached;
31 } else {
32 2 my $value = $code->();
33 2 $self->set( $key => $value );
34 2 return $value;
35 }
36 }
37  
38 # ex: set sw=4 et:
39  
40 7 __PACKAGE__;
41  
42  
43 __END__
« Ref/CLOCK/Base.pm ↑ Summary Ref/LRU.pm »