| 1 | # Copyright (c) 2024-2026 Philipp Schafft | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Work with Tag databases | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | package Data::TagDB::LinkIterator; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use parent 'Data::TagDB::Iterator'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 4 | our $VERSION = v0.16; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 21 | 0 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | foreach my $required (qw(db query package tag_keys raw_keys)) { | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | croak 'Missing required member: '.$required unless defined $opts{$required}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | return bless \%opts, $pkg; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 32 | 0 | my Data::TagDB $db = $self->db; | |||||||||||||||||||||||||||
| 33 | 0 | my $row = $self->{query}->fetchrow_hashref; | |||||||||||||||||||||||||||
| 34 | 0 | my %args; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return undef unless defined $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | foreach my $key (keys %{$self->{tag_keys}}) { | |||||||||||||||||||||||||||
| 39 | 0 | my $value = $row->{$self->{tag_keys}{$key}}; | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | next unless defined($value) && $value > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value > 0
MC/DC0%0/2
defined $value and $value > 0
defined $value
$value > 0
Truth table0%0/3
A and B
A= defined $valueB= $value > 0
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | $args{$key} = $db->tag_by_dbid($value); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | foreach my $key (keys %{$self->{raw_keys}}) { | |||||||||||||||||||||||||||
| 46 | 0 | my $value = $row->{$self->{raw_keys}{$key}}; | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | next unless defined($value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | $args{$key} = $value; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | return $self->{package}->_new(%args, _row => $row, db => $db); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub finish { | ||||||||||||||||||||||||||
|
Subroutine
finish: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 57 | 0 | $self->{query}->finish; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 4 | 1; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||