Mango/BSON/Document.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 10 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 95.6% 44 / 46 CC 8 SCAR 10.1
CC
8
Cov
97%
DELETE
5.0
NEXTKEY
2.0
STORE
2.0
CRAP 2.7
« Mango/Auth/SCRAM.pm ↑ Summary Mango/BSON/ObjectID.pm »
1 package Mango::BSON::Document;
2 11 ▶use Mojo::Base 'Tie::Hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 ▶sub DELETE {
Subroutine DELETE: called CC=5 SCAR=16.1
5 2 my ($self, $key) = @_;
6 2 ▶ return undef unless exists $self->[0]{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->[0]{$key} 1 1 2
7 1 $key eq $self->[1][$_] and splice @{$self->[1]}, $_, 1 and last
8 1 ▶ for 0 .. $#{$self->[1]};
Branch: 1 branch
BranchTrueFalseTotal
$key eq $self->[1][$_] and splice @{$$self[1];}, $_, 1 and last 1 1 2
Condition66%2/3
$key eq $self->[1][$_] and splice @{$$self[1];}, $_, 1
!ll&&!rl&&r
101
MC/DC50%1/2
$key eq $self->[1][$_] and splice @{$$self[1];}, $_, 1
$key eq $self->[1][$_] splice @{$$self[1];}, $_, 1
Truth table66%2/3
A and B
A= $key eq $self->[1][$_]B= splice @{$$self[1];}, $_, 1
ABresult
0X0
100
111
9 1 return delete $self->[0]{$key};
10 }
11  
12 110 ▶sub EXISTS { exists $_[0][0]{$_[1]} }
Subroutine EXISTS: called CC=1 SCAR=0.0
13  
14 177 ▶sub FETCH { $_[0][0]{$_[1]} }
Subroutine FETCH: called CC=1 SCAR=0.0
15  
16 125 ▶sub FIRSTKEY {
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
17 125 $_[0][2] = 0;
18 125 &NEXTKEY;
19 }
20  
21 284 ▶sub NEXTKEY { $_[0][2] <= $#{$_[0][1]} ? $_[0][1][$_[0][2]++] : undef }
Subroutine NEXTKEY: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0][2] <= $#{$_[0][1];} ? : 159 125 284
22  
23 112 ▶sub STORE {
Subroutine STORE: called CC=2 SCAR=6.9
24 112 my ($self, $key, $value) = @_;
25 112 ▶ push @{$self->[1]}, $key unless exists $self->[0]{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->[0]{$key} 111 1 112
26 112 $self->[0]{$key} = $value;
27 }
28  
29 91 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=2 SCAR=6.9
30 91 my $self = bless [{}, [], 0], shift;
31 91 ▶ $self->STORE(shift, shift) while @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ and do { $self->STORE(shift(), shift()) } 109 91 200
32 91 return $self;
33 }
34  
35 11 1;
36  
37 =encoding utf8
38  
39 =head1 NAME
40  
41 Mango::BSON::Document - Document type
42  
43 =head1 SYNOPSIS
44  
45 use Mango::BSON::Document;
46  
47 tie my %hash, 'Mango::BSON::Document';
48  
49 =head1 DESCRIPTION
50  
51 L<Mango::BSON::Document> is a container for the BSON document type used by
52 L<Mango::BSON>.
53  
54 =head1 SEE ALSO
55  
56 L<Mango>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
57  
58 =cut
« Mango/Auth/SCRAM.pm ↑ Summary Mango/BSON/ObjectID.pm »