BSON/ObjectId.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 100% 8 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 90.0% 9 / 10 Podpod 25.0% 1 / 4 totaltotal 91.9% 57 / 62 CC 6 SCAR 9.3
CC
6
Cov
98%
value
5.0
new
2.0
to_s
2.0
CRAP 2.5
« BSON/String.pm ↑ Summary BSON/Bool.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::ObjectId;
6 # ABSTRACT: Legacy BSON type wrapper for Object IDs (DEPRECATED)
7  
8 71 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 71 our $VERSION = 'v1.12.1';
10  
11 71 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 71 ▶use BSON::OID;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 71 our @ISA = qw/BSON::OID/;
15  
16 sub new {
17 8892 ▶ my ( $class, $value ) = @_;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
18 8892 my $self = bless {}, $class;
19 8892 ▶ if ( $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 7 8885 8892
20 7 $self->value( $value );
21 }
22 else {
23 8885 $self->{oid} = BSON::OID::_packed_oid();
24 }
25 8890 return $self;
26 }
27  
28 sub value {
29 9 ▶ my ( $self, $new_value ) = @_;
Subroutine value: called CC=5 SCAR=16.1
Pod undocumented
30 9 ▶ if ( defined $new_value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_value) 7 2 9
31 7 ▶ if ( length($new_value) == 12 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $new_value == 12) { } 2 5 7
elsif (length $new_value == 24 and $self->is_legal($new_value)) { } 3 2 5
32 2 $self->{oid} = $new_value;
33 }
34 ▶ elsif ( length($new_value) == 24 && $self->is_legal($new_value) ) {
Condition100%3/3
length $new_value == 24 and $self->is_legal($new_value)
!ll&&!rl&&r
113
MC/DC100%2/2
length $new_value == 24 and $self->is_legal($new_value)
length $new_value == 24 $self->is_legal($new_value)
Truth table100%3/3
A and B
A= length $new_value == 24B= $self->is_legal($new_value)
ABresult
0X0
100
111
35 3 $self->{oid} = pack("H*", $new_value);
36 }
37 else {
38 2 croak("BSON::ObjectId must be a 12 byte or 24 char hex value");
39 }
40 }
41 7 return $self->{oid};
42 }
43  
44 sub is_legal {
45 5 ▶ $_[1] =~ /^[0-9a-f]{24}$/i;
Subroutine is_legal: called CC=1 SCAR=0.0
Pod undocumented
46 }
47  
48 0 ▶sub to_s { $_[0]->to_string }
Subroutine to_s: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 71 1;
51  
52 =pod
53  
54 =encoding UTF-8
55  
56 =head1 NAME
57  
58 BSON::ObjectId - Legacy BSON type wrapper for Object IDs (DEPRECATED)
59  
60 =head1 VERSION
61  
62 version v1.12.1
63  
64 =head1 DESCRIPTION
65  
66 This module has been deprecated as it was not compatible with
67 the official MongoDB BSON implementation on CPAN.
68  
69 You are strongly encouraged to use L<BSON::OID> instead.
70  
71 =for Pod::Coverage to_s is_legal new value
72  
73 =head1 AUTHORS
74  
75 =over 4
76  
77 =item *
78  
79 David Golden <david@mongodb.com>
80  
81 =item *
82  
83 Stefan G. <minimalist@lavabit.com>
84  
85 =back
86  
87 =head1 COPYRIGHT AND LICENSE
88  
89 This software is Copyright (c) 2019 by Stefan G. and MongoDB, Inc.
90  
91 This is free software, licensed under:
92  
93 The Apache License, Version 2.0, January 2004
94  
95 =cut
96  
97 __END__
« BSON/String.pm ↑ Summary BSON/Bool.pm »