lib/DR/Tnt/Msgpack/Types/Bool.pm

filter: Statementstmt 91.8% 34 / 37 Branchbran 75.0% 9 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 80.3% 53 / 66 SCAR 21.1
CC
8
Cov
85%
TO_JSON
5.8
new
3.1
TO_MSGPACK
2.0
CRAP 8.2
« blib/lib/DR/Tnt/Role/Logging.pm ↑ Summary lib/DR/Tnt/Client/AE.pm »
1 11 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DR::Tnt::Msgpack::Types::Bool;
6 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 $Carp::Internal{ (__PACKAGE__) }++;
8 11 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub new {
12 22 ▶ my ($class, $value) = @_;
Subroutine new: called CC=3 SCAR=11.4
Pod undocumented
13  
14 22 ▶ $value = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 12 10 22
15 22 ▶ bless \$value => ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0220
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
16 }
17  
18 sub TO_MSGPACK {
19 4 ▶ my ($self) = @_;
Subroutine TO_MSGPACK: called CC=2 SCAR=6.9
Pod undocumented
20 4 ▶ return pack 'C', 0xC3 if $$self;
Branch: 1 branch
BranchTrueFalseTotal
if $$self 2 2 4
21 2 return pack 'C', 0xC2;
22 }
23  
24 sub TO_JSON {
25 4 ▶ my ($self) = @_;
Subroutine TO_JSON: called CC=5 SCAR=17.6
Pod undocumented
26  
27 4 state ($true, $false);
28  
29 4 ▶ unless (defined $true) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $true) 1 3 4
30 1 ▶ if (eval "require JSON::XS; 1") {
Branch: 2 branches
BranchTrueFalseTotal
if (eval 'require JSON::XS; 1') { } 1 0 1
elsif (eval 'require JSON; 1') { } 0 0 0
31 1 $true = JSON::XS::true();
32 1 $false = JSON::XS::false();
33 } elsif (eval "require JSON; 1") {
34 0 $true = JSON::true();
35 0 $false = JSON::false();
36 } else {
37 0 croak "JSON or JSON::XS must be installed";
38 }
39 }
40  
41 4 ▶ return $true if $$self;
Branch: 1 branch
BranchTrueFalseTotal
if $$self 2 2 4
42 2 return $false;
43 }
44  
45 =head1 NAME
46  
47 DR::Tnt::Msgpack::Types::Bool - container for bool.
48  
49 =head1 SYNOPSIS
50  
51 use DR::Tnt::Msgpack::Types::Bool;
52  
53 my $o = DR::Tnt::Msgpack::Types::Bool->new(1);
54 my $blob = msgpack($o);
55  
56 =head1 DESCRIPTION
57  
58 See L<DR::Tnt::Msgpack::Types>.
59  
60 =cut
61  
62 11 1;
« blib/lib/DR/Tnt/Role/Logging.pm ↑ Summary lib/DR/Tnt/Client/AE.pm »