lib/DB/Object/Placeholder.pm

filter: Statementstmt 100% 61 / 61 Branchbran 58.3% 7 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 16 / 16 Podpod 100% 6 / 6 totaltotal 91.0% 91 / 100 CC 8 SCAR 9.7
CC
8
Cov
91%
replace
6.6
init
2.0
has
2.0
CRAP 2.6
« blib/lib/DB/Object/Postgres/Lo.pm ↑ Summary lib/DB/Object/Postgres.pm »
1 ##----------------------------------------------------------------------------
2 ## Database Object Interface - ~/lib/DB/Object/Placeholder.pm
3 ## Version v0.13.0
4 ## Copyright(c) 2026 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2023/07/08
7 ## Modified 2026/03/22
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.
12 ##----------------------------------------------------------------------------
13 package DB::Object::Placeholder;
14 BEGIN
15 3 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 warnings::register_categories( 'DB::Object' );
19 3 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶ use vars qw( $REGISTRY $VERSION $EXCEPTION_CLASS );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶ use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 3 ▶ use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
23 '""' => 'as_string',
24 78 ▶ 'bool' => sub{1},
Subroutine __ANON__: called CC=1 SCAR=0.0
25 3 );
26 3 our $REGISTRY = {};
27 3 our $EXCEPTION_CLASS = $DB::Object::EXCEPTION_CLASS;
28 3 our $VERSION = 'v0.13.0';
29 };
30  
31 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 sub init
35 39 ▶{
Subroutine init: called CC=2 SCAR=6.9
Pod documented
36 39 my $self = shift( @_ );
37 39 $self->{type} = undef;
38 39 $self->{value} = undef;
39 39 $self->{_init_strict_use_sub} = 1;
40 39 $self->{_exception_class} = $EXCEPTION_CLASS;
41 39 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 39 0 39
42 39 my $addr = Scalar::Util::refaddr( $self );
43 39 $REGISTRY->{ $addr } = $self;
44 39 return( $self );
45 }
46  
47 sub as_string
48 3 ▶{
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
49 3 my $self = shift( @_ );
50 3 my $addr = Scalar::Util::refaddr( $self );
51 3 return( "__PLACEHOLDER__${addr}__" );
52 }
53  
54 sub has
55 36 ▶{
Subroutine has: called CC=2 SCAR=6.9
Pod documented
56 36 my $self = shift( @_ );
57 36 my $str = shift( @_ );
58 36 ▶ $str = Scalar::Util::reftype( $str ) eq 'SCALAR' ? $str : \$str;
Branch: 1 branch
BranchTrueFalseTotal
builtin::reftype($str) eq 'SCALAR' ? : 35 1 36
59 36 return( CORE::index( $$str, '__PLACEHOLDER__' ) != -1 );
60 }
61  
62 sub replace
63 2 ▶{
Subroutine replace: called CC=6 SCAR=18.8
Pod documented
64 2 my $self = shift( @_ );
65 2 my $str = shift( @_ );
66 2 ▶ $str = Scalar::Util::reftype( $str ) eq 'SCALAR' ? $str : \$str;
Branch: 1 branch
BranchTrueFalseTotal
builtin::reftype($str) eq 'SCALAR' ? : 2 0 2
67 2 ▶ return if( !defined( $$str ) || !length( $$str ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$str and length $$str 0 2 2
Condition33%1/3
defined $$str and length $$str
!ll&&!rl&&r
002
MC/DC0%0/2
defined $$str and length $$str
defined $$str length $$str
Truth table33%1/3
A and B
A= defined $$strB= length $$str
ABresult
0X0
100
111
68 2 my $types = $self->new_array( [] );
69 2 my $values = $self->new_array( [] );
70 2 $$str =~ s
71 {
72 __PLACEHOLDER__(\d+)__
73 }
74 {
75 3 ▶ if( exists( $REGISTRY->{ $1 } ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $DB::Object::Placeholder::REGISTRY->{$1}) 3 0 3
76 {
77 3 my $p = $REGISTRY->{ $1 };
78 3 push( @$types, $p->type );
79 3 push( @$values, $p->value );
80 }
81 3 "?";
82 }gexm;
83 2 ▶ return( wantarray() ? ( $types, $$str ) : $types );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
84 }
85  
86 5 ▶sub type { return( shift->_set_get_scalar( 'type', @_ ) ); }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
87  
88 4 ▶sub value { return( shift->_set_get_scalar( 'value', @_ ) ); }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
89  
90 3 1;
91 # NOTE: POD
92 __END__
« blib/lib/DB/Object/Postgres/Lo.pm ↑ Summary lib/DB/Object/Postgres.pm »