| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Meta CPAN API - ~/lib/Net/API/CPAN/Filter.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2023 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2023/08/03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2023/08/03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | package Net::API::CPAN::Filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | our $VERSION = 'v0.1.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=13 SCAR=28.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | $self->{aggs} = undef unless( CORE::exists( $self->{aggs} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | $self->{es} = undef unless( CORE::exists( $self->{es} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | $self->{fields} = undef unless( CORE::exists( $self->{fields} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | $self->{filter} = undef unless( CORE::exists( $self->{filter} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | $self->{from} = undef unless( CORE::exists( $self->{from} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | $self->{match_all} = 0 unless( CORE::exists( $self->{match_all} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | $self->{name} = undef unless( CORE::exists( $self->{name} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | $self->{query} = undef unless( CORE::exists( $self->{query} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | $self->{size} = undef unless( CORE::exists( $self->{size} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | $self->{sort} = undef unless( CORE::exists( $self->{sort} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | $self->{source} = undef unless( CORE::exists( $self->{source} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | $self->{_data} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub aggregations { return( shift->aggs( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aggregations: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub aggs { return( shift->reset(@_)->_set_get_hash_as_mix_object( 'aggs', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aggs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | sub apply | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $hash = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | return( $self ) if( !scalar( keys( %$hash ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | foreach my $k ( keys( %$hash ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # if( !CORE::exists( $dict->{ $k } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if( !( $code = $self->can( $k ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | warn( "No method \"$k\" found in class ", ( ref( $self ) || $self ), " when applying data to this object. Skipping it." ) if( $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $code->( $self, $hash->{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub as_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | return( $self->{_data_cache} ) if( $self->{_data_cache} && !CORE::length( $self->{_reset} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_data_cache"} and not length $self->{"_reset"}
MC/DC0%0/2
$self->{"_data_cache"} and not length $self->{"_reset"}
$self->{"_data_cache"}
not length $self->{"_reset"}
Truth table0%0/3
A and not(B)
A= $self->{"_data_cache"}B= not length $self->{"_reset"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $es = $self->es; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if( defined( $es ) && $es->length ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $es and $es->length
MC/DC0%0/2
defined $es and $es->length
defined $es
$es->length
Truth table0%0/3
A and B
A= defined $esB= $es->length
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $data = $es->as_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $data->{query} = $self->query; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if( my $aggs = $self->aggs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $data->{aggs} = $aggs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if( my $fields = $self->fields ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $data->{fields} = [@$fields] if( !$fields->is_empty ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if( my $filter = $self->filter ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $data->{filter} = $filter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if( my $sort = $self->sort ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $data->{sort} = [@$sort] if( !$sort->is_empty ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if( my $source = $self->source ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $data->{_source} = $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if( my $name = $self->name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if( exists( $data->{filter} ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $data->{"filter"} and exists $data->{"filter"}{"terms"} and ref $data->{"filter"}{"terms"} eq "HASH"
exists $data->{"filter"} and exists $data->{"filter"}{"terms"}
MC/DC0%0/3
exists $data->{"filter"} and exists $data->{"filter"}{"terms"} and ref $data->{"filter"}{"terms"} eq "HASH"
exists $data->{"filter"}
exists $data->{"filter"}{"terms"}
ref $data->{"filter"}{"terms"} eq "HASH"
Truth table0%0/4
A and B and C
A= exists $data->{"filter"}B= exists $data->{"filter"}{"terms"}C= ref $data->{"filter"}{"terms"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | exists( $data->{filter}->{terms} ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ref( $data->{filter}->{terms} ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $data->{filter}->{terms}->{_name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if( defined( my $from = $self->from ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $data->{from} = $from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if( defined( my $size = $self->size ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $data->{size} = $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->{_data_cache} = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | CORE::delete( $self->{_reset} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | sub as_json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_json: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $data = $self->as_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $j = $self->new_json; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $j = $j->pretty if( $opts->{pretty} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $j = $j->canonical if( $opts->{sort} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $json; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if( exists( $opts->{encoding} ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
exists $opts->{"encoding"} and defined $opts->{"encoding"} and lc $opts->{"encoding"} eq "utf-8" || lc $opts->{"encoding"} eq "utf8"
exists $opts->{"encoding"} and defined $opts->{"encoding"}
lc $opts->{"encoding"} eq "utf-8" or lc $opts->{"encoding"} eq "utf8"
MC/DC0%0/4
exists $opts->{"encoding"} and defined $opts->{"encoding"} and lc $opts->{"encoding"} eq "utf-8" || lc $opts->{"encoding"} eq "utf8"
exists $opts->{"encoding"}
defined $opts->{"encoding"}
lc $opts->{"encoding"} eq "utf-8"
lc $opts->{"encoding"} eq "utf8"
Truth table0%0/5
A and B and C or D
A= exists $opts->{"encoding"}B= defined $opts->{"encoding"}C= lc $opts->{"encoding"} eq "utf-8"D= lc $opts->{"encoding"} eq "utf8"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | defined( $opts->{encoding} ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ( lc( $opts->{encoding} ) eq 'utf-8' || lc( $opts->{encoding} ) eq 'utf8' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $json = $j->utf8->encode( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $json = $j->encode( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return( $self->error( "Error encoding to JSON: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return( $json ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub es { return( shift->reset(@_)->_set_get_hash_as_mix_object( 'es', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
es: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub fields { return( shift->reset(@_)->_set_get_array_as_object( 'fields', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub filter { return( shift->reset(@_)->_set_get_hash_as_mix_object( 'filter', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub from { return( shift->reset(@_)->_set_get_number( 'from', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | sub match_all { return( shift->reset(@_)->_set_get_number( 'match_all', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match_all: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub name { return( shift->reset(@_)->_set_get_scalar_as_object( 'name', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | sub query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $query; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | return( $self->error( "Argument to query must be an hash reference." ) ) if( ref( $this ) ne 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | $self->message( 5, "Query provided is -> ", sub{ $self->Module::Generic::dump( $this ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->reset(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my @es_ops = qw( bool should ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $es_ops = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | @$es_ops{ @es_ops } = (1) x scalar( @es_ops ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my @operators = ( 'all', 'bool', 'either', 'not', 'must', 'shall', 'shall not', 'should' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $op_re = join( '|', @operators ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $equi = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | all => 'must', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | either => 'should', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | not => 'must_not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $build; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | $build = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $ref = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | $self->message( 5, "Top properties are: ", sub{ join( ', ', sort( keys( %$ref ) ) ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $q = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if( scalar( grep( /^($op_re)$/, keys( %$ref ) ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | foreach my $op ( @operators ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | next unless( exists( $ref->{ $op } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $def = delete( $ref->{ $op } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # No need for transformation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if( exists( $es_ops->{ $op } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $q->{ $op } = $def; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | $def = [$def] if( ref( $def ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if( !$self->_is_array( $def ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return( $self->error( "Invalid parameter \"$op\" value provided (", overload::StrVal( $def ), "). I was expecting an hash or an array reference." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $sub_q = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | foreach my $sub_def ( @$def ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | my $this_q = $build->( $sub_def ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&$build($sub_def) || (return $self->pass_error)
MC/DC0%0/1
&$build($sub_def) || (return $self->pass_error)
&$build($sub_def)
Truth table0%0/2
A
A= &$build($sub_def)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | push( @$sub_q, $this_q ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $q->{bool} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $q->{bool}->{ $equi->{ $op } // $op } = $sub_q; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$equi->{$op} // $op
MC/DC0%0/2
$equi->{$op} // $op
$equi->{$op}
$op
Truth table0%0/3
A // B
A= $equi->{$op}B= $op
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | $self->message( 5, "Top properties do not contain either of ", sub{ join( ', ', @operators ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $n = scalar( keys( %$ref ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return( $self->error( "Wrong number of keys (${n}). Query element should have only 1 key. Insted I got: ", sub{ $self->Module::Generic::dump( $ref ) } ) ) if( $n > 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $key = [keys( %$ref )]->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $val = $ref->{ $key }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # $ref = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # status => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # value => "latest", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # boost => 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if( ref( $val ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $q->{term} = $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # or, just: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # $ref = { status => "latest" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # or, maybe: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # $ref = { name => "Some*" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ▶ | elsif( ( !ref( $val ) || $self->_can_overload( $val => '""' ) ) && "$val" =~ /[\w\*]/ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
!ref($val) || $self->_can_overload($val, "\"\"") and "$val" =~ /[\w\*]/
not ref $val or $self->_can_overload($val, "\"\"")
MC/DC0%0/3
!ref($val) || $self->_can_overload($val, "\"\"") and "$val" =~ /[\w\*]/
not ref $val
$self->_can_overload($val, "\"\"")
"$val" =~ /[\w\*]/
Truth table0%0/5
not(A) or B and C
A= not ref $valB= $self->_can_overload($val, "\"\"")C= "$val" =~ /[\w\*]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | my $type = ( "$val" =~ /[*?]/ ? 'wildcard' : 'term' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $q->{ $type } = $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return( $self->error( "Wrong value for \"$key\". I do not know what to do with '", overload::StrVal( $val ), "'" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return( $q ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | $query = $build->( $this ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&$build($this) || (return $self->pass_error)
MC/DC0%0/1
&$build($this) || (return $self->pass_error)
&$build($this)
Truth table0%0/2
A
A= &$build($this)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $self->{query} = $query; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | unless( $self->{query} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $match_all = $self->match_all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if( $match_all ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if( $match_all == 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $self->{query} = { match_all => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->{query} = { match_all => { boost => $match_all } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return( $self->{query} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | sub reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 5 | ▶ | if( ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%6/8
not exists $self->{"_reset"} && defined $self->{"_reset"} && length $self->{"_reset"} and scalar @_
exists $self->{'_reset'} && defined $self->{'_reset'} && length $self->{'_reset'}
exists $self->{"_reset"} and defined $self->{"_reset"}
MC/DC33%1/3
not exists $self->{"_reset"} && defined $self->{"_reset"} && length $self->{"_reset"} and scalar @_
exists $self->{"_reset"}
defined $self->{"_reset"}
length $self->{'_reset'}
Truth table50%2/4
not(A and B && C)
A= exists $self->{"_reset"}B= defined $self->{"_reset"}C= length $self->{'_reset'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | !exists( $self->{_reset} ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | !defined( $self->{_reset} ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | !CORE::length( $self->{_reset} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | ) && scalar( @_ ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $self->{_reset} = scalar( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | ▶ | sub size { return( shift->reset(@_)->_set_get_number( 'size', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub sort { return( shift->reset(@_)->_set_get_array_as_object( 'sort', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | sub source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if( !defined( $_[0] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->{source} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $self->reset(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | ▶ | elsif( $self->_is_array( $_[0] ) || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$self->_is_array($_[0]) or not ref $_[0] or ref $_[0] and $self->_can_overload($_[0], "\"\"")
$self->_is_array($_[0]) or not ref $_[0]
ref $_[0] and $self->_can_overload($_[0], "\"\"")
MC/DC0%0/4
$self->_is_array($_[0]) or not ref $_[0] or ref $_[0] and $self->_can_overload($_[0], "\"\"")
$self->_is_array($_[0])
not ref $_[0]
ref $_[0]
$self->_can_overload($_[0], "\"\"")
Truth table0%0/5
A or not(B) or C and D
A= $self->_is_array($_[0])B= not ref $_[0]C= ref $_[0]D= $self->_can_overload($_[0], "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | !ref( $_[0] ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ( ref( $_[0] ) && $self->_can_overload( $_[0] => '""' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $self->{source} = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $self->reset(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return( $self->error( "A source can only be either a string or an array reference." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | return( $self->{source} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | sub TO_JSON { return( shift->as_hash ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||