blib/lib/Bot/Cobalt/Core/Role/Singleton.pm

filter: Statementstmt 65.3% 17 / 26 Branchbran 0.0% 0 / 2 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 62.5% 5 / 8 Podpod 75.0% 3 / 4 totaltotal 52.0% 26 / 50 CC 4 SCAR 11.4
CC
4
Cov
53%
instance
6.0
clear_instance
6.0
has_instance
2.1
CRAP 3.1
« blib/lib/Bot/Cobalt/Plugin/Games/Magic8.pm ↑ Summary blib/lib/Bot/Cobalt/IRC/Server.pm »
1 package Bot::Cobalt::Core::Role::Singleton;
2 1 $Bot::Cobalt::Core::Role::Singleton::VERSION = '0.021001';
3 1 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub instance {
11 0 ▶ my $class = $_[0];
Subroutine instance: not called CC=2 SCAR=17.9
Pod documented
12  
13 0 my $this_obj = \${$class.'::_singleton'};
14
15 0 ▶ defined $$this_obj ? $$this_obj
Branch: 1 branch
BranchTrueFalseTotal
defined $$this_obj ? : 0 0 0
16 : ( $$this_obj = $class->new(@_[1 .. $#_]) )
17 }
18  
19 sub has_instance {
20 2 ▶ my $class = ref $_[0] || $_[0];
Subroutine has_instance: called CC=2 SCAR=7.6
Pod documented
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
21 2 !! ${$class.'::_singleton'};
22 }
23  
24 sub clear_instance {
25 0 ▶ my $class = ref $_[0] || $_[0];
Subroutine clear_instance: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
26 0 ${$class.'::_singleton'} = undef;
27 0 1
28 }
29  
30 sub is_instanced {
31 0 ▶ confess "is_instanced is deprecated; use has_instance"
Subroutine is_instanced: not called CC=1 SCAR=6.9
Pod undocumented
32 }
33  
34 1 1;
35 __END__
« blib/lib/Bot/Cobalt/Plugin/Games/Magic8.pm ↑ Summary blib/lib/Bot/Cobalt/IRC/Server.pm »