EO/Singleton.pm

filter: Statementstmt 73.9% 17 / 23 Branchbran 0.0% 0 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 5 / 8 Podpod 100% 4 / 4 totaltotal 63.6% 28 / 44 CC 4 SCAR 11.3
CC
4
Cov
63%
get
6.0
set
6.0
new
2.0
CRAP 3.1
« EO/Hash.pm ↑ Summary EO/Class.pm »
1 package EO::Singleton;
2  
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use EO;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our @ISA = qw( EO );
8 4 our $VERSION = 0.96;
9 4 my $_singletons = {};
10  
11 15 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
12 15 my $class = shift;
13 15 ▶ $_singletons->{$class} ||= $class->SUPER::new(@_);
Condition66%2/3
$_singletons->{$class} ||= $class->SUPER::new(@_)
l!l&&r!l&&!r
780
MC/DC0%0/2
$_singletons->{$class} ||= $class->SUPER::new(@_)
$_singletons->{$class} $class->SUPER::new(@_)
Truth table66%2/3
A ||= B
A= $_singletons->{$class}B= $class->SUPER::new(@_)
ABresult
1X1
011
000
14 }
15  
16 0 ▶sub _reset_singleton {
Subroutine _reset_singleton: not called CC=1 SCAR=6.9
17 0 my $self = shift;
18 0 $_singletons->{ ref($self) } = $self;
19 }
20  
21 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
22 0 ▶ my $self = ref($_[0]) ? shift : shift->new;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
23 0 $self->SUPER::get( @_ );
24 }
25  
26 0 ▶sub set {
Subroutine set: not called CC=2 SCAR=17.9
Pod documented
27 0 ▶ my $self = ref($_[0]) ? shift : shift->new;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
28 0 $self->SUPER::set( @_ );
29 }
30  
31 1 ▶sub clone {
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
32 1 my $self = shift;
33 1 return $self;
34 }
35  
36 4 1;
37  
38 __END__
« EO/Hash.pm ↑ Summary EO/Class.pm »