Identifier/Interface/Known.pm

filter: Statementstmt 51.6% 31 / 60 Branchbran 18.1% 4 / 22 Conditioncond 25.0% 2 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 44.1% 45 / 102 CC 15 SCAR 38.0
CC
15
Cov
41%
known
69.1
_known_provider
12.0
BEGIN
1.0
CRAP 44.7
« Identifier/Interface/Subobjects.pm ↑ Summary Identifier/Util.pm »
1 # Copyright (c) 2023-2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: format independent identifier object
6  
7  
8 package Data::Identifier::Interface::Known;
9  
10 8 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 8 ▶use Data::Identifier;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 8 our $VERSION = v0.38;
18  
19 8 my @_subobjects = qw(db extractor store fii);
20  
21  
22 5 ▶sub known {
Subroutine known: called CC=13 SCAR=42.4
Pod documented
23 5 my ($pkg, $class, %opts) = @_;
24 5 ▶ my $as = $opts{as} // 'raw';
Condition100%2/2
$opts{"as"} // "raw"
l!l
14
MC/DC100%1/1
$opts{"as"} // "raw"
$opts{"as"}
Truth table100%2/2
A
A= $opts{"as"}
Aresult
11
00
25 5 my ($list, %extra) = eval {$pkg->_known_provider($class)};
26 5 my $listas = $opts{listas};
27  
28 5 ▶ if (defined $list) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $list) 5 0 5
29 5 ▶ if ($extra{not_identifiers}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra{'not_identifiers'}) { } 0 5 5
30 0 ▶ if (!defined($listas)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $listas) 0 0 0
31 0 ▶ if ($as eq 'raw' || (defined($extra{rawtype}) && $as eq $extra{rawtype})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($as eq "raw" or defined $extra{"rawtype"} and $as eq $extra{"rawtype"}) 0 0 0
Condition0%0/6
$as eq "raw" or defined $extra{"rawtype"} and $as eq $extra{"rawtype"}
l!l&&r!l&&!r
000
defined $extra{"rawtype"} and $as eq $extra{"rawtype"}
!ll&&!rl&&r
000
MC/DC0%0/3
$as eq "raw" or defined $extra{"rawtype"} and $as eq $extra{"rawtype"}
$as eq "raw" defined $extra{"rawtype"} $as eq $extra{"rawtype"}
Truth table0%0/4
A or B and C
A= $as eq "raw"B= defined $extra{"rawtype"}C= $as eq $extra{"rawtype"}
ABCresult
1XX1
0111
00X0
0100
32 0 return @{$list};
33 }
34 }
35  
36 0 ▶ if ($opts{skip_invalid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"skip_invalid"}) 0 0 0
37 # Let us try again with only identifiers:
38 0 my @res;
39  
40 0 @res = grep {defined} map {eval {$_->Data::Identifier::as($as, %opts{@_subobjects, qw(no_defaults)}, %extra{qw(rawtype)})}} @{$list};
41  
42 0 ▶ if (defined($listas)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $listas) 0 0 0
43 0 require Data::Identifier::Cloudlet;
44 0 return Data::Identifier::Cloudlet->new(root => \@res, %opts{@_subobjects})->as($listas, %opts{@_subobjects});
45 }
46  
47 0 return @res;
48 }
49 } else {
50 5 my @res;
51  
52 5 ▶ if ($opts{skip_invalid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'skip_invalid'}) { } 0 5 5
53 0 @res = grep {defined} map {eval {$_->Data::Identifier::as($as, %opts{@_subobjects, qw(no_defaults)}, %extra{qw(rawtype)})}} @{$list};
54 } else {
55 5 @res = map {$_->Data::Identifier::as($as, %opts{@_subobjects, qw(no_defaults)}, %extra{qw(rawtype)})} @{$list};
56 }
57  
58 5 ▶ if (defined($listas)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $listas) 0 5 5
59 0 require Data::Identifier::Cloudlet;
60 0 return Data::Identifier::Cloudlet->new(root => \@res, %opts{@_subobjects})->as($listas, %opts{@_subobjects});
61 }
62  
63 5 return @res;
64 }
65 }
66  
67 0 ▶ return @{$opts{default}} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
68 0 croak 'Unsupported class or options';
69 }
70  
71  
72 0 ▶sub _known_provider {
Subroutine _known_provider: not called CC=3 SCAR=24.8
73 0 my ($pkg, $class, %opts) = @_;
74 0 ▶ croak 'Unsupported options passed' if scalar(keys %opts);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
75 0 ▶ return ([]) if $class eq ':all';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq ":all" 0 0 0
76 0 croak 'Unsupported class';
77 }
78  
79  
80  
81 8 1;
82  
83 __END__
« Identifier/Interface/Subobjects.pm ↑ Summary Identifier/Util.pm »