| 1 | package Farly::Object::List; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use 5.008008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 16 | our $VERSION = '0.26'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 211 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 211 | my ($class) = @_; | |||||||||||||||||||||||||||
| 12 | 211 | return bless [], $class; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1157 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 1157 | my ( $self, $object ) = @_; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1157 | ▶ | croak "Farly::Object object required" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | unless ( $object->isa('Farly::Object') ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1157 | push @$self, $object; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 157 | ▶ | sub iter { | ||||||||||||||||||||||||||
|
Subroutine
iter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 157 | return @{ $_[0] }; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 28 | ▶ | sub size { | ||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 28 | return scalar( @{ $_[0] } ); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | sub clone { | ||||||||||||||||||||||||||
|
Subroutine
clone: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | my $result = Farly::Object::List->new(); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | foreach my $object ( $self->iter() ) { | |||||||||||||||||||||||||||
| 38 | 3 | $result->add( $object->clone() ); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | return $result; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 4 | ▶ | sub includes { | ||||||||||||||||||||||||||
|
Subroutine
includes: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 4 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 4 | foreach my $object ( $self->iter() ) { | |||||||||||||||||||||||||||
| 48 | 6 | ▶ | if ( $object->matches($other) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 4 | return 1; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 21 | ▶ | sub matches { | ||||||||||||||||||||||||||
|
Subroutine
matches: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 21 | my ( $self, $other, $result ) = @_; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 21 | $self->_validate( $other, $result ); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 21 | foreach my $object ( $self->iter() ) { | |||||||||||||||||||||||||||
| 60 | 589 | ▶ | if ( $object->matches($other) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 131 | $result->add($object); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | ▶ | sub contains { | ||||||||||||||||||||||||||
|
Subroutine
contains: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 1 | my ( $self, $other, $result ) = @_; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 1 | $self->_validate( $other, $result ); | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | foreach my $object ( $self->iter() ) { | |||||||||||||||||||||||||||
| 72 | 3 | ▶ | if ( $object->contains($other) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 1 | $result->add($object); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 7 | ▶ | sub contained_by { | ||||||||||||||||||||||||||
|
Subroutine
contained_by: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | 7 | my ( $self, $other, $result ) = @_; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 7 | $self->_validate( $other, $result ); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 7 | foreach my $object ( $self->iter() ) { | |||||||||||||||||||||||||||
| 84 | 390 | ▶ | if ( $object->contained_by($other) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 4 | $result->add($object); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub intersects { | ||||||||||||||||||||||||||
|
Subroutine
intersects: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my ( $self, $other, $result ) = @_; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | $self->_validate( $other, $result ); | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | foreach my $object ( $self->iter() ) { | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ( $object->intersects($other) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | $result->add($object); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 1 | ▶ | sub search { | ||||||||||||||||||||||||||
|
Subroutine
search: called CC=6 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 1 | my ( $self, $other, $result ) = @_; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 1 | $self->_validate( $other, $result ); | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | foreach my $object ( $self->iter() ) { | |||||||||||||||||||||||||||
| 108 | 3 | ▶ | if ( $object->matches($other) ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 109 | 1 | $result->add($object); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | elsif ( $object->contains($other) ) { | ||||||||||||||||||||||||||||
| 112 | 0 | $result->add($object); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | elsif ( $object->contained_by($other) ) { | ||||||||||||||||||||||||||||
| 115 | 0 | $result->add($object); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | elsif ( $object->intersects($other) ) { | ||||||||||||||||||||||||||||
| 118 | 0 | $result->add($object); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 30 | ▶ | sub _validate { | ||||||||||||||||||||||||||
|
Subroutine
_validate: called CC=6 SCAR=20.7
| |||||||||||||||||||||||||||||
| 124 | 30 | my ( $self, $other, $result ) = @_; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 30 | ▶ | confess "other not defined" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | unless ( defined $other ); | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 30 | ▶ | confess "container for result required" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | unless ( defined $result ); | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 30 | ▶ | confess "the search object must be an Farly::Object or Farly::Object::Ref" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | unless ( $other->isa("Farly::Object") ); | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 30 | ▶ | confess "the result container must be an Farly::Object::List or Farly::Object::Set" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$result->isa("Farly::Object::List") or $result->isa("Farly::Object::Set")
MC/DC0%0/2
$result->isa("Farly::Object::List") or $result->isa("Farly::Object::Set")
$result->isa("Farly::Object::List")
$result->isa("Farly::Object::Set")
Truth table33%1/3
A or B
A= $result->isa("Farly::Object::List")B= $result->isa("Farly::Object::Set")
| |||||||||||||||||||||||||||||
| 136 | unless ( $result->isa("Farly::Object::List") || $result->isa("Farly::Object::Set") ); | ||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 16 | 1; | |||||||||||||||||||||||||||
| 140 | __END__ | ||||||||||||||||||||||||||||