blib/lib/Tags/Element.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 40 / 40 SCAR 19.5
CC
7
Cov
100%
element
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
↑ Summary
1 package Tags::Element;
2  
3 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Constants.
10 3 Readonly::Array our @EXPORT_OK => qw(element);
11  
12 # Version.
13 3 our $VERSION = 0.03;
14  
15 # Common element.
16 sub element {
17 8 ▶ my ($element, @data) = @_;
Subroutine element: called CC=7 SCAR=19.5
Pod documented
18 8 my @attr;
19 my @content;
20 8 foreach my $ref (@data) {
21 10 ▶ if (ref $ref eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $ref eq 'HASH') { } 4 6 10
elsif (ref $ref eq 'ARRAY') { } 3 3 6
22 4 foreach my $key (sort keys %{$ref}) {
23 3 push @attr, ['a', $key, $ref->{$key}];
24 }
25 } elsif (ref $ref eq 'ARRAY') {
26 3 push @content, @{$ref};
27 } else {
28 3 push @content, ['d', $ref];
29 }
30 }
31 return (
32 8 ▶ ['b', $element],
Branch: 2 branches
BranchTrueFalseTotal
@attr ? : 3 5 8
@content ? : 5 3 8
33 @attr ? @attr : (),
34 @content ? @content : (),
35 ['e', $element],
36 );
37 }
38  
39 3 1;
40  
41 __END__
↑ Summary