| 1 | 25 | ▶ | use 5.20.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 25 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package DBIx::Class::Smooth::Q; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # ABSTRACT: Short intro | ||||||||||||||||||||||||||||
| 8 | 25 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||||||||||
| 9 | 25 | our $VERSION = '0.0108'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 25 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 25 | ▶ | use Safe::Isa qw/$_isa/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 25 | ▶ | use List::SomeUtils qw/any/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 25 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 25 | ▶ | use Sub::Exporter::Progressive -setup => { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | exports => [qw/Q/], | ||||||||||||||||||||||||||||
| 17 | groups => { | ||||||||||||||||||||||||||||
| 18 | default => [qw/Q/], | ||||||||||||||||||||||||||||
| 19 | }, | ||||||||||||||||||||||||||||
| 20 | 25 | }; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | use overload | ||||||||||||||||||||||||||||
| 23 | 25 | ▶ | '&' => 'do_and', | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | '|' => 'do_or', | ||||||||||||||||||||||||||||
| 25 | 25 | '~' => 'do_not'; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 25 | ▶ | use experimental qw/signatures postderef/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 25 | has value => ( | |||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 37 | ▶ | sub Q(@args) { | ||||||||||||||||||||||||||
|
Subroutine
Q: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 37 | ▶ | if(scalar @args == 1 && $args[0]->$_isa('DBIx::Class::Smooth::Q')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @args == 1 and $args[0]->$DBIx::Class::Smooth::Q::_isa("DBIx::Class::Smooth::Q")
MC/DC50%1/2
scalar @args == 1 and $args[0]->$DBIx::Class::Smooth::Q::_isa("DBIx::Class::Smooth::Q")
scalar @args == 1
$args[0]->$DBIx::Class::Smooth::Q::_isa("DBIx::Class::Smooth::Q")
Truth table66%2/3
A and B
A= scalar @args == 1B= $args[0]->$DBIx::Class::Smooth::Q::_isa("DBIx::Class::Smooth::Q")
| |||||||||||||||||||||||||||||
| 35 | 3 | return $args[0]; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 34 | return DBIx::Class::Smooth::Q->new(value => [-and => \@args]); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 12 | ▶ | sub _prepare_do_and($self, $other) { | ||||||||||||||||||||||||||
|
Subroutine
_prepare_do_and: called CC=4 SCAR=22.1
| |||||||||||||||||||||||||||||
| 41 | 12 | my %self_values_as_flathash = ($self->value->[1]->@*); | |||||||||||||||||||||||||||
| 42 | 12 | my @self_valuekeys = keys %self_values_as_flathash; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 12 | ▶ | if(any { $_ eq '-and' } @self_valuekeys) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | ATTEMPT: | ||||||||||||||||||||||||||||
| 46 | 0 | while(1) { | |||||||||||||||||||||||||||
| 47 | VALUE: | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | for (my $i = 0; $i < scalar $self->value->[1]->@*; $i += 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | my $key = $self->value->[1][$i]; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | if($key eq '-and') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | push $other->value->[1]->@* => $self->value->[1][$i+1]->@*; | |||||||||||||||||||||||||||
| 52 | 0 | splice $self->value->[1]->@*, $i, 2; | |||||||||||||||||||||||||||
| 53 | 0 | next ATTEMPT; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 0 | last ATTEMPT; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 12 | return $self, $other; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 12 | ▶ | sub do_and($self, $other, $swap) { | ||||||||||||||||||||||||||
|
Subroutine
do_and: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 12 | ($self, $other) = $self->_prepare_do_and($other); | |||||||||||||||||||||||||||
| 65 | 12 | my $self_value = $self->value; | |||||||||||||||||||||||||||
| 66 | 12 | my $other_value = $other->value; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 12 | ▶ | if($self_value->[0] eq '-and') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 9 | $self_value = $self_value->[1]; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 12 | ▶ | if($other_value->[0] eq '-and') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 9 | $other_value = $other_value->[1]; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 12 | my $value = [-and => [$self_value->@*, $other_value->@* ]]; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 12 | return DBIx::Class::Smooth::Q->new(value => $value); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 15 | ▶ | sub do_or($self, $other, $swap) { | ||||||||||||||||||||||||||
|
Subroutine
do_or: called CC=9 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 15 | my $self_value = $self->value; | |||||||||||||||||||||||||||
| 82 | 15 | my $other_value = $other->value; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 15 | ▶ | if($self_value->[0] eq '-or' && $self_value->[1][0] eq '-or') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self_value->[0] eq "-or" and $self_value->[1][0] eq "-or"
MC/DC100%2/2
$self_value->[0] eq "-or" and $self_value->[1][0] eq "-or"
$self_value->[0] eq "-or"
$self_value->[1][0] eq "-or"
Truth table100%3/3
A and B
A= $self_value->[0] eq "-or"B= $self_value->[1][0] eq "-or"
| |||||||||||||||||||||||||||||
| 85 | 4 | splice $self_value->[1]->@*, 0, 2, $self_value->[1][1]->@*; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 15 | ▶ | if($other_value->[0] eq '-or' && $other_value->[1][0] eq '-or') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$other_value->[0] eq "-or" and $other_value->[1][0] eq "-or"
MC/DC0%0/2
$other_value->[0] eq "-or" and $other_value->[1][0] eq "-or"
$other_value->[0] eq "-or"
$other_value->[1][0] eq "-or"
Truth table33%1/3
A and B
A= $other_value->[0] eq "-or"B= $other_value->[1][0] eq "-or"
| |||||||||||||||||||||||||||||
| 88 | 0 | splice $other_value->[1]->@*, 0, 2, $other_value->[1][1]->@*; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 15 | ▶ | if($self_value->[0] eq '-and' && scalar $self_value->[1]->@* == 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self_value->[0] eq "-and" and scalar @{$self_value->[1]} == 2
MC/DC100%2/2
$self_value->[0] eq "-and" and scalar @{$self_value->[1]} == 2
$self_value->[0] eq "-and"
scalar @{$self_value->[1]} == 2
Truth table100%3/3
A and B
A= $self_value->[0] eq "-and"B= scalar @{$self_value->[1]} == 2
| |||||||||||||||||||||||||||||
| 92 | 6 | $self_value = $self_value->[1]; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 15 | ▶ | if($other_value->[0] eq '-and' && scalar $other_value->[1]->@* == 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$other_value->[0] eq "-and" and scalar @{$other_value->[1]} == 2
MC/DC0%0/2
$other_value->[0] eq "-and" and scalar @{$other_value->[1]} == 2
$other_value->[0] eq "-and"
scalar @{$other_value->[1]} == 2
Truth table33%1/3
A and B
A= $other_value->[0] eq "-and"B= scalar @{$other_value->[1]} == 2
| |||||||||||||||||||||||||||||
| 95 | 15 | $other_value = $other_value->[1]; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | 15 | my $value = [-or => [$self_value->@*, $other_value->@* ]]; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 15 | return DBIx::Class::Smooth::Q->new(value => $value); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub do_not($self, $undef, $swap) { | ||||||||||||||||||||||||||
|
Subroutine
do_not: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 0 | return DBIx::Class::Smooth::Q->new(value => [-not_bool => [$self->value->@*]]); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 25 | 1; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | __END__ | ||||||||||||||||||||||||||||