Shared/Scalar.pm

filter: Statementstmt 50.8% 29 / 57 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 36.8% 7 / 19 Podpod 100% 9 / 9 totaltotal 44.1% 45 / 102 CC 7 SCAR 12.9
CC
7
Cov
42%
TIESCALAR
6.0
append
6.0
decrby
6.0
CRAP 3.6
« Shared/Hash.pm ↑ Summary
1 ###############################################################################
2 ## ----------------------------------------------------------------------------
3 ## Scalar helper class.
4 ##
5 ###############################################################################
6  
7 package MCE::Shared::Scalar;
8  
9 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 15 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 15 ▶no warnings qw( threads recursion uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 15 our $VERSION = '1.894';
17  
18 ## no critic (TestingAndDebugging::ProhibitNoStrict)
19  
20 15 ▶use MCE::Shared::Base ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 15 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
23 15 q("") => \&MCE::Shared::Base::_stringify,
24 q(0+) => \&MCE::Shared::Base::_numify,
25 fallback => 1
26 15 );
27  
28 # Based on Tie::StdScalar from Tie::Scalar.
29  
30 0 ▶sub TIESCALAR {
Subroutine TIESCALAR: not called CC=2 SCAR=17.9
31 0 my $class = shift;
32 0 ▶ bless \do{ my $o = defined $_[0] ? shift : undef }, $class;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 0 0 0
33 }
34  
35 0 ▶sub STORE { ${ $_[0] } = $_[1] }
Subroutine STORE: not called CC=1 SCAR=6.9
36 0 ▶sub FETCH { ${ $_[0] } }
Subroutine FETCH: not called CC=1 SCAR=6.9
37  
38 ###############################################################################
39 ## ----------------------------------------------------------------------------
40 ## Sugar API, mostly resembles https://redis.io/commands#string primitives.
41 ##
42 ###############################################################################
43  
44 # append ( string )
45  
46 0 ▶sub append {
Subroutine append: not called CC=2 SCAR=17.9
Pod documented
47 0 ▶ length( ${ $_[0] } .= $_[1] // '' );
Condition0%0/2
$_[1] // ""
l!l
00
MC/DC0%0/1
$_[1] // ""
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
48 }
49  
50 # decr
51 # decrby ( number )
52 # incr
53 # incrby ( number )
54 # getdecr
55 # getincr
56  
57 0 ▶sub decr { --${ $_[0] } }
Subroutine decr: not called CC=1 SCAR=6.9
Pod documented
58 0 ▶sub decrby { ${ $_[0] } -= $_[1] || 0 }
Subroutine decrby: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[1] || 0
l!l
00
MC/DC0%0/1
$_[1] || 0
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
59 0 ▶sub incr { ++${ $_[0] } }
Subroutine incr: not called CC=1 SCAR=6.9
Pod documented
60 0 ▶sub incrby { ${ $_[0] } += $_[1] || 0 }
Subroutine incrby: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[1] || 0
l!l
00
MC/DC0%0/1
$_[1] || 0
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
61 0 ▶sub getdecr { ${ $_[0] }-- // 0 }
Subroutine getdecr: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
${$_[0];}-- // 0
l!l
00
MC/DC0%0/1
${$_[0];}-- // 0
${$_[0];}--
Truth table0%0/2
A
A= ${$_[0];}--
Aresult
11
00
62 0 ▶sub getincr { ${ $_[0] }++ // 0 }
Subroutine getincr: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
${$_[0];}++ // 0
l!l
00
MC/DC0%0/1
${$_[0];}++ // 0
${$_[0];}++
Truth table0%0/2
A
A= ${$_[0];}++
Aresult
11
00
63  
64 # getset ( value )
65  
66 0 ▶sub getset {
Subroutine getset: not called CC=1 SCAR=6.9
Pod documented
67 0 my $old = ${ $_[0] };
68 0 ${ $_[0] } = $_[1];
69  
70 0 $old;
71 }
72  
73 # len ( )
74  
75 0 ▶sub len {
Subroutine len: not called CC=1 SCAR=6.9
Pod documented
76 0 length ${ $_[0] };
77 }
78  
79 {
80 15 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 15 *{ __PACKAGE__.'::new' } = \&TIESCALAR;
83 15 *{ __PACKAGE__.'::set' } = \&STORE;
84 15 *{ __PACKAGE__.'::get' } = \&FETCH;
85 }
86  
87 15 1;
88  
89 __END__
« Shared/Hash.pm ↑ Summary