| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 31 | 7 | ▶ | if ( length($new_value) == 12 ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 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)
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)
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||