Fluent/Elements/Base.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 88.8% 32 / 36 CC 9 SCAR 21.3
CC
9
Cov
88%
__ANON__
9.2
BEGIN
1.0
CRAP 8.4
« Fluent/ResourceGroup.pm ↑ Summary Fluent/Elements/InlineExpression.pm »
1 package Translate::Fluent::Elements::Base;
2  
3 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 708 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=9 SCAR=22.2
6 708 my ($orig, $class, @args) = @_;
7  
8 0 ▶ my %args = ref $args[0] ? %{ $args[0] } : @args;
Branch: 1 branch
BranchTrueFalseTotal
ref $args[0] ? : 0 708 708
9  
10 708 for my $k (keys %args) {
11 1596 my $val = delete $args{ $k };
12  
13 1596 ▶ if (ref $val eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $val eq 'HASH') { } 350 1246 1596
elsif (ref $val eq 'ARRAY') { } 184 1062 1246
14
15 350 my $res = Translate::Fluent::Elements->create(
16 $k, $val
17 );
18
19 350 ▶ $val = $res if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 350 0 350
20  
21 } elsif (ref $val eq 'ARRAY') {
22 184 my @items;
23 184 for my $item ( @$val ) {
24 280 my ($type) = keys %$item;
25 my $itemval = ref $item->{$type}
26 ? $item->{$type}
27 280 ▶ : { text => $item->{$type} };
Branch: 1 branch
BranchTrueFalseTotal
ref $item->{$type} ? : 128 152 280
28 280 my $res = Translate::Fluent::Elements->create(
29 $type => $itemval
30 );
31  
32 280 ▶ push @items, $res ? $res : $item;
Branch: 1 branch
BranchTrueFalseTotal
$res ? : 280 0 280
33 }
34  
35 184 $val = \@items;
36 }
37  
38 1596 $args{ "\L$k" } = $val;
39 }
40  
41 708 return $class->$orig( %args );
42 6 };
43  
44 6 1;
45  
46 __END__
« Fluent/ResourceGroup.pm ↑ Summary Fluent/Elements/InlineExpression.pm »