| 1 | package Data::Predicate; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 8 | our $VERSION = '2.1.1'; | |||||||||||||||||||
| 7 | 8 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 77 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||
| 10 | 77 | my ($class) = @_; | |||||||||||||||||||
| 11 | 77 | ▶ | $class = ref($class) || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 12 | 77 | my $self = bless({}, $class); | |||||||||||||||||||
| 13 | 77 | return $self; | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | ▶ | sub apply { | ||||||||||||||||||
|
Subroutine
apply: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 17 | 0 | confess('Not implemented at this level'); | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 1 | ▶ | sub filter { | ||||||||||||||||||
|
Subroutine
filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 21 | 1 | my ($self, $values) = @_; | |||||||||||||||||||
| 22 | 1 | return [ grep { $self->apply($_) } @{$values}]; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 1 | ▶ | sub filter_transform { | ||||||||||||||||||
|
Subroutine
filter_transform: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 26 | 1 | my ($self, $values, $transformer) = @_; | |||||||||||||||||||
| 27 | 1 | my @transformed; | |||||||||||||||||||
| 28 | 1 | foreach my $value (@{$values}) { | |||||||||||||||||||
| 29 | 7 | ▶ | if($self->apply($value)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 3 | push(@transformed, $transformer->($value)); | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | 1 | return \@transformed; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 2 | ▶ | sub all_true { | ||||||||||||||||||
|
Subroutine
all_true: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 37 | 2 | my ($self, $objects) = @_; | |||||||||||||||||||
| 38 | 2 | my $count = $self->_count_truth($objects); | |||||||||||||||||||
| 39 | 2 | ▶ | return (scalar(@{$objects}) == $count) ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 2 | ▶ | sub all_false { | ||||||||||||||||||
|
Subroutine
all_false: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 43 | 2 | my ($self, $objects) = @_; | |||||||||||||||||||
| 44 | 2 | my $count = $self->_count_truth($objects); | |||||||||||||||||||
| 45 | 2 | ▶ | return ($count == 0) ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 4 | ▶ | sub _count_truth { | ||||||||||||||||||
|
Subroutine
_count_truth: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 49 | 4 | my ($self, $objects) = @_; | |||||||||||||||||||
| 50 | 4 | my $count = 0; | |||||||||||||||||||
| 51 | 4 | foreach my $obj (@{$objects}) { | |||||||||||||||||||
| 52 | 24 | ▶ | $count++ if $self->apply($obj); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | 4 | return $count; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 8 | 1; | |||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||