BSON/Doc.pm

filter: Statementstmt 91.8% 34 / 37 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 90.7% 49 / 54 CC 4 SCAR 5.3
CC
4
Cov
93%
new
3.0
_as_tied_hash
2.0
__ANON__
2.0
CRAP 1.7
« BSON/Types.pm ↑ Summary BSON/Binary.pm »
1 71 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 71 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 71 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package BSON::Doc;
6 # ABSTRACT: BSON type wrapper for ordered documents
7  
8 71 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 71 our $VERSION = 'v1.12.2';
10  
11 71 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 71 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 61 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
15 61 my ( $class, @args ) = @_;
16  
17 61 ▶ croak "BSON::Doc::new requires key/value pairs"
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 != 0 41 20 61
18 if @args % 2 != 0;
19  
20 20 my $key_count =()= keys %{{@args}};
21 20 ▶ croak "Duplicate keys not allowed in BSON::Doc"
Branch: 1 branch
BranchTrueFalseTotal
if $key_count * 2 != @args 1 19 20
22 if $key_count * 2 != @args;
23  
24 19 return bless \@args, $class;
25 }
26  
27 0 ▶sub _as_tied_hash {
Subroutine _as_tied_hash: not called CC=1 SCAR=6.9
28 0 my $self = shift;
29 0 tie my %h, 'Tie::IxHash', @$self;
30 0 return \%h;
31 }
32  
33 17 ▶sub _iterator {
Subroutine _iterator: called CC=1 SCAR=0.0
34 17 my $self = shift;
35 17 my $index = 0;
36 40 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
37 40 ▶ return if $index > $#{$self};
Branch: 1 branch
BranchTrueFalseTotal
if $index > $#{$self;} 17 23 40
38 23 my ($k,$v) = @{$self}[$index, $index+1];
39 23 $index += 2;
40 23 return ($k,$v);
41 }
42 17 }
43  
44 71 1;
45  
46 =pod
47  
48 =encoding UTF-8
49  
50 =head1 NAME
51  
52 BSON::Doc - BSON type wrapper for ordered documents
53  
54 =head1 VERSION
55  
56 version v1.12.2
57  
58 =head1 SYNOPSIS
59  
60 use BSON::Types ':all';
61  
62 my $ordered = bson_doc( first => 1, second => 2 );
63  
64 =head1 DESCRIPTION
65  
66 This module provides a BSON type wrapper representing a document preserves
67 key-value order. It is currently read-only.
68  
69 =for Pod::Coverage new
70  
71 =head1 AUTHORS
72  
73 =over 4
74  
75 =item *
76  
77 David Golden <david@mongodb.com>
78  
79 =item *
80  
81 Stefan G. <minimalist@lavabit.com>
82  
83 =back
84  
85 =head1 COPYRIGHT AND LICENSE
86  
87 This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
88  
89 This is free software, licensed under:
90  
91 The Apache License, Version 2.0, January 2004
92  
93 =cut
94  
95 __END__
« BSON/Types.pm ↑ Summary BSON/Binary.pm »