Catmandu/Fix/substring.pm

filter: Statementstmt 98.2% 56 / 57 Branchbran 87.5% 7 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 13 / 13 Podpod n/a totaltotal 95.0% 77 / 81 CC 6 SCAR 5.1
CC
6
Cov
96%
_build_fixer
3.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.7
« Catmandu/MultiIterator.pm ↑ Summary Catmandu/Fix/expand.pm »
1 package Catmandu::Fix::substring;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.2025';
6  
7 1 ▶use Catmandu::Util qw(as_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 has path => (fix_arg => 1);
14 1 has args => (fix_arg => 'collect');
15  
16 1 with 'Catmandu::Fix::Builder';
17  
18 5 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=3 SCAR=11.0
19 5 my ($self) = @_;
20 5 my $args = $self->args;
21 5 my $cb;
22  
23 5 ▶ if (@$args == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@$args == 1) { } 1 4 5
elsif (@$args == 2) { } 3 1 4
24 2 ▶ $cb = sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
25 2 my $val = $_[0];
26 2 my $new_val;
27 2 eval {
28 1 ▶ no warnings 'substr';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 $new_val = substr(as_utf8($val), $args->[0]);
30 };
31 2 ▶ return $new_val if defined $new_val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_val 2 0 2
32 0 return undef, 1, 0;
33 1 };
34 }
35 elsif (@$args == 2) {
36 3 ▶ $cb = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
37 3 my $val = $_[0];
38 3 my $new_val;
39 3 eval {
40 1 ▶ no warnings 'substr';
Subroutine BEGIN: called CC=1 SCAR=0.0
41 3 $new_val = substr(as_utf8($val), $args->[0], $args->[1]);
42 };
43 3 ▶ return $new_val if defined $new_val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_val 1 2 3
44 2 return undef, 1, 0;
45 3 };
46 }
47 else {
48 1 ▶ $cb = sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
49 1 my $val = $_[0];
50 1 my $new_val = as_utf8($val);
51 1 ▶ eval {
Condition50%1/2
eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} substr($new_val, $args->[0], $args->[1]) = $args->[2] } } // (return undef, 1, 0)
l!l
10
MC/DC0%0/1
eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} substr($new_val, $args->[0], $args->[1]) = $args->[2] } } // (return undef, 1, 0)
eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} substr($new_val, $args->[0], $args->[1]) = $args->[2] } }
Truth table50%1/2
A
A= eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} substr($new_val, $args->[0], $args->[1]) = $args->[2] } }
Aresult
11
00
52 1 ▶ no warnings 'substr';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 substr($new_val, $args->[0], $args->[1]) = $args->[2];
54 } // return undef, 1, 0;
55 1 $new_val;
56 1 };
57 }
58  
59 5 as_path($self->path)->updater(if_value => $cb);
60 }
61  
62 1 1;
63  
64 __END__
« Catmandu/MultiIterator.pm ↑ Summary Catmandu/Fix/expand.pm »