| 1 | package MaxMind::DB::Types; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | our $VERSION = '0.040001'; | |||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Carp qw( confess ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use Exporter qw( import ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use List::AllUtils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use Scalar::Util (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use Sub::Quote qw( quote_sub ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use overload (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 2 | our @EXPORT_OK = qw( | |||||||||
| 16 | ArrayRefOfStr | ||||||||||
| 17 | Bool | ||||||||||
| 18 | Decoder | ||||||||||
| 19 | Epoch | ||||||||||
| 20 | FileHandle | ||||||||||
| 21 | HashRef | ||||||||||
| 22 | HashRefOfStr | ||||||||||
| 23 | Int | ||||||||||
| 24 | Metadata | ||||||||||
| 25 | Str | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | ## no critic (NamingConventions::Capitalization, ValuesAndExpressions::ProhibitImplicitNewlines) | ||||||||||
| 29 | { | ||||||||||
| 30 | 2 | my $t = quote_sub( | |||||||||
| 31 | q{ | ||||||||||
| 32 | ( | ||||||||||
| 33 | defined $_[0] | ||||||||||
| 34 | && Scalar::Util::reftype( $_[0] ) eq 'ARRAY' | ||||||||||
| 35 | && List::AllUtils::all( | ||||||||||
| 36 | sub { defined $_ && !ref $_ }, | ||||||||||
| 37 | @{ $_[0] } | ||||||||||
| 38 | ) | ||||||||||
| 39 | ) | ||||||||||
| 40 | or MaxMind::DB::Types::_confess( | ||||||||||
| 41 | '%s is not an arrayref', | ||||||||||
| 42 | $_[0] | ||||||||||
| 43 | ); | ||||||||||
| 44 | } | ||||||||||
| 45 | ); | ||||||||||
| 46 | |||||||||||
| 47 | 2 | ▶ | sub ArrayRefOfStr () { $t } | ||||||||
|
Subroutine
ArrayRefOfStr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | { | ||||||||||
| 51 | 2 | my $t = quote_sub( | |||||||||
| 52 | q{ | ||||||||||
| 53 | ( !defined $_[0] || $_[0] eq q{} || "$_[0]" eq '1' || "$_[0]" eq '0' ) | ||||||||||
| 54 | or MaxMind::DB::Types::_confess( | ||||||||||
| 55 | '%s is not a boolean', | ||||||||||
| 56 | $_[0] | ||||||||||
| 57 | ); | ||||||||||
| 58 | } | ||||||||||
| 59 | ); | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub Bool () { $t } | ||||||||
|
Subroutine
Bool: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | { | ||||||||||
| 65 | 2 | my $t = _object_isa_type('MaxMind::DB::Reader::Decoder'); | |||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub Decoder () { $t } | ||||||||
|
Subroutine
Decoder: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | { | ||||||||||
| 71 | 2 | my $t = quote_sub( | |||||||||
| 72 | q{ | ||||||||||
| 73 | ( | ||||||||||
| 74 | defined $_[0] && ( ( !ref $_[0] && $_[0] =~ /^[0-9]+$/ ) | ||||||||||
| 75 | || ( Scalar::Util::blessed( $_[0] ) | ||||||||||
| 76 | && ( $_[0]->isa('Math::UInt128') || $_[0]->isa('Math::BigInt') ) ) | ||||||||||
| 77 | ) | ||||||||||
| 78 | ) | ||||||||||
| 79 | or MaxMind::DB::Types::_confess( | ||||||||||
| 80 | '%s is not an integer, a Math::UInt128 object, or a Math::BigInt object', | ||||||||||
| 81 | $_[0] | ||||||||||
| 82 | ); | ||||||||||
| 83 | } | ||||||||||
| 84 | ); | ||||||||||
| 85 | |||||||||||
| 86 | 2 | ▶ | sub Epoch () { $t } | ||||||||
|
Subroutine
Epoch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 87 | |||||||||||
| 88 | 10 | ▶ | sub Int () { $t } | ||||||||
|
Subroutine
Int: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | { | ||||||||||
| 92 | 2 | my $t = quote_sub( | |||||||||
| 93 | q{ | ||||||||||
| 94 | ( ( defined $_[0] && Scalar::Util::openhandle( $_[0] ) ) | ||||||||||
| 95 | || ( Scalar::Util::blessed( $_[0] ) && $_[0]->isa('IO::Handle') ) ) | ||||||||||
| 96 | or MaxMind::DB::Types::_confess( | ||||||||||
| 97 | '%s is not a file handle', | ||||||||||
| 98 | $_[0] | ||||||||||
| 99 | ); | ||||||||||
| 100 | } | ||||||||||
| 101 | ); | ||||||||||
| 102 | |||||||||||
| 103 | 0 | ▶ | sub FileHandle () { $t } | ||||||||
|
Subroutine
FileHandle: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | { | ||||||||||
| 107 | 2 | my $t = quote_sub( | |||||||||
| 108 | q{ | ||||||||||
| 109 | ( defined $_[0] && Scalar::Util::reftype( $_[0] ) eq 'HASH' ) | ||||||||||
| 110 | or MaxMind::DB::Types::_confess( | ||||||||||
| 111 | '%s is not a hashref', | ||||||||||
| 112 | $_[0] | ||||||||||
| 113 | ); | ||||||||||
| 114 | } | ||||||||||
| 115 | ); | ||||||||||
| 116 | |||||||||||
| 117 | 0 | ▶ | sub HashRef () { $t } | ||||||||
|
Subroutine
HashRef: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | { | ||||||||||
| 121 | 2 | my $t = quote_sub( | |||||||||
| 122 | q{ | ||||||||||
| 123 | ( | ||||||||||
| 124 | defined $_[0] | ||||||||||
| 125 | && Scalar::Util::reftype( $_[0] ) eq 'HASH' | ||||||||||
| 126 | && &List::AllUtils::all( | ||||||||||
| 127 | sub { defined $_ && !ref $_ }, values %{ $_[0] } | ||||||||||
| 128 | ) | ||||||||||
| 129 | ) | ||||||||||
| 130 | or MaxMind::DB::Types::_confess( | ||||||||||
| 131 | '%s is not a hashref of strings', | ||||||||||
| 132 | $_[0] | ||||||||||
| 133 | ); | ||||||||||
| 134 | } | ||||||||||
| 135 | ); | ||||||||||
| 136 | |||||||||||
| 137 | 2 | ▶ | sub HashRefOfStr () { $t } | ||||||||
|
Subroutine
HashRefOfStr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 138 | } | ||||||||||
| 139 | |||||||||||
| 140 | { | ||||||||||
| 141 | 2 | my $t = _object_isa_type('MaxMind::DB::Metadata'); | |||||||||
| 142 | |||||||||||
| 143 | 0 | ▶ | sub Metadata () { $t } | ||||||||
|
Subroutine
Metadata: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 144 | } | ||||||||||
| 145 | |||||||||||
| 146 | { | ||||||||||
| 147 | 2 | my $t = quote_sub( | |||||||||
| 148 | q{ | ||||||||||
| 149 | ( defined $_[0] && !ref $_[0] ) | ||||||||||
| 150 | or MaxMind::DB::Types::_confess( '%s is not a string', $_[0] ); | ||||||||||
| 151 | } | ||||||||||
| 152 | ); | ||||||||||
| 153 | |||||||||||
| 154 | 2 | ▶ | sub Str () { $t } | ||||||||
|
Subroutine
Str: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 155 | } | ||||||||||
| 156 | |||||||||||
| 157 | 2 | ▶ | sub _object_isa_type { | ||||||||
|
Subroutine
_object_isa_type: called CC=1 SCAR=0.0
| |||||||||||
| 158 | 4 | my $class = shift; | |||||||||
| 159 | |||||||||||
| 160 | 4 | return quote_sub( | |||||||||
| 161 | qq{ | ||||||||||
| 162 | ( Scalar::Util::blessed( \$_[0] ) && \$_[0]->isa('$class') ) | ||||||||||
| 163 | or MaxMind::DB::Types::_confess( | ||||||||||
| 164 | '%s is not a $class object', | ||||||||||
| 165 | \$_[0] | ||||||||||
| 166 | ); | ||||||||||
| 167 | } | ||||||||||
| 168 | ); | ||||||||||
| 169 | } | ||||||||||
| 170 | ## use critic | ||||||||||
| 171 | |||||||||||
| 172 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||
| 173 | 0 | ▶ | sub _confess { | ||||||||
|
Subroutine
_confess: not called CC=2 SCAR=17.9
| |||||||||||
| 174 | ## no critic (Subroutines::ProhibitCallsToUnexportedSubs) | ||||||||||
| 175 | 0 | ▶ | confess sprintf( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 176 | $_[0], | ||||||||||
| 177 | defined $_[1] ? overload::StrVal( $_[1] ) : 'undef' | ||||||||||
| 178 | ); | ||||||||||
| 179 | } | ||||||||||
| 180 | ## use critic | ||||||||||
| 181 | |||||||||||
| 182 | 2 | 1; | |||||||||