blib/lib/OPTIMADE/Filter/ListComparison.pm

filter: Statementstmt 94.7% 54 / 57 Branchbran 71.4% 10 / 14 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 8 totaltotal 82.2% 79 / 96 SCAR 23.2
CC
10
Cov
89%
validate
5.6
to_filter
4.0
operator
2.0
CRAP 10.1
« blib/lib/OPTIMADE/Filter/Zip.pm ↑ Summary Build »
1 package OPTIMADE::Filter::ListComparison;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use parent 'OPTIMADE::Filter::Modifiable';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 our $VERSION = '0.10.2'; # VERSION
10  
11 sub new {
12 22 ▶ my( $class, $operator ) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
13 22 return bless { property => undef,
14 operator => $operator,
15 values => undef }, $class;
16 }
17  
18 sub property {
19 46 ▶ my( $self, $property ) = @_;
Subroutine property: called CC=2 SCAR=6.9
Pod undocumented
20 46 my $previous_property = $self->{property};
21 46 ▶ $self->{property} = $property if defined $property;
Branch: 1 branch
BranchTrueFalseTotal
if defined $property 24 22 46
22 46 return $previous_property;
23 }
24  
25 sub operator {
26 20 ▶ my( $self, $operator ) = @_;
Subroutine operator: called CC=2 SCAR=7.0
Pod undocumented
27 20 my $previous_operator = $self->{operator};
28 20 ▶ $self->{operator} = $operator if defined $operator;
Branch: 1 branch
BranchTrueFalseTotal
if defined $operator 0 20 20
29 20 return $previous_operator;
30 }
31  
32 sub values {
33 42 ▶ my( $self, $values ) = @_;
Subroutine values: called CC=2 SCAR=6.9
Pod undocumented
34 42 my $previous_values = $self->{values};
35 42 ▶ $self->{values} = $values if defined $values;
Branch: 1 branch
BranchTrueFalseTotal
if defined $values 22 20 42
36 42 return $previous_values;
37 }
38  
39 sub to_filter {
40 20 ▶ my( $self ) = @_;
Subroutine to_filter: called CC=4 SCAR=13.9
Pod undocumented
41 20 $self->validate;
42  
43 20 my @values;
44 20 for my $i (0..$#{$self->{values}}) {
45 50 my( $operator, $arg ) = @{$self->{values}[$i]};
46 50 ▶ if( blessed $arg && $arg->can( 'to_filter' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($arg) and $arg->can('to_filter')) { } 2 48 50
Condition66%2/3
builtin::blessed($arg) and $arg->can("to_filter")
!ll&&!rl&&r
4802
MC/DC50%1/2
builtin::blessed($arg) and $arg->can("to_filter")
builtin::blessed($arg) $arg->can("to_filter")
Truth table66%2/3
A and B
A= builtin::blessed($arg)B= $arg->can("to_filter")
ABresult
0X0
100
111
47 2 $arg = $arg->to_filter;
48 } else {
49 48 $arg =~ s/\\/\\\\/g;
50 48 $arg =~ s/"/\\"/g;
51 48 $arg = "\"$arg\"";
52 }
53 50 push @values, "$operator $arg";
54 }
55  
56 return '(' . join( ' ', $self->{property}->to_filter,
57 $self->{operator},
58 20 join( ', ', @values ) ) . ')';
59 }
60  
61 sub to_SQL
62 {
63 10 ▶ die "no SQL representation\n";
Subroutine to_SQL: called CC=1 SCAR=0.0
Pod undocumented
64 }
65  
66 sub modify {
67 2 ▶ my $self = shift;
Subroutine modify: called CC=1 SCAR=0.0
Pod undocumented
68 2 my $code = shift;
69  
70 2 $self->property( $self->property->modify( $code, @_ ) );
71 6 $self->{values} = [ map { [ OPTIMADE::Filter::Modifiable::modify( $_->[0], $code, @_ ),
72 OPTIMADE::Filter::Modifiable::modify( $_->[1], $code, @_ ) ] }
73 2 @{$self->{values}} ];
74 2 return $code->( $self, @_ );
75 }
76  
77 sub validate
78 {
79 20 ▶ my $self = shift;
Subroutine validate: called CC=4 SCAR=17.2
Pod undocumented
80  
81 20 ▶ if( !$self->property ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->property) 0 20 20
82 0 die 'property undefined for OPTIMADE::Filter::ListComparison';
83 }
84 20 ▶ if( !$self->operator ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->operator) 0 20 20
85 0 die 'operator undefined for OPTIMADE::Filter::ListComparison';
86 }
87 20 ▶ if( !$self->values ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->values) 0 20 20
88 0 die 'values undefined for OPTIMADE::Filter::ListComparison';
89 }
90 }
91  
92 5 1;
« blib/lib/OPTIMADE/Filter/Zip.pm ↑ Summary Build »