lib/PHP/Decode.pm

filter: Statementstmt 71.7% 33 / 46 Branchbran 50.0% 17 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 100% 5 / 5 totaltotal 65.6% 63 / 96 CC 18 SCAR 26.1
CC
18
Cov
62%
new
22.9
_log_cb
20.0
_warn_cb
4.0
CRAP 13.6
« blib/lib/PHP/Decode/Array.pm ↑ Summary lib/PHP/Decode/Array.pm »
1 #
2 # parse and transform PHP source files
3 #
4 package PHP::Decode;
5  
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use PHP::Decode::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use PHP::Decode::Transformer;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $VERSION = '0.302';
12  
13 721 ▶sub new {
Subroutine new: called CC=12 SCAR=31.3
Pod documented
14 721 my ($class, %args) = @_;
15  
16 my $parser = PHP::Decode::Parser->new(strmap => {},
17 exists $args{inscript} ? (inscript => $args{inscript}) : (),
18 exists $args{filename} ? (filename => $args{filename}) : (),
19 exists $args{max_strlen} ? (max_strlen => $args{max_strlen}) : (),
20 exists $args{log} ? (log => $args{log}) : (),
21 exists $args{debug} ? (debug => $args{debug}) : (),
22 721 ▶ exists $args{warn} ? (warn => $args{warn}) : ());
Branch: 6 branches
BranchTrueFalseTotal
exists $args{'inscript'} ? : 721 0 721
exists $args{'filename'} ? : 0 721 721
exists $args{'max_strlen'} ? : 0 721 721
exists $args{'log'} ? : 0 721 721
exists $args{'debug'} ? : 0 721 721
exists $args{'warn'} ? : 721 0 721
23  
24 my $ctx = PHP::Decode::Transformer->new(parser => $parser,
25 exists $args{skip} ? (skip => $args{skip}) : (),
26 exists $args{with} ? (with => $args{with}) : (),
27 exists $args{max_loop} ? (max_loop => $args{max_loop}) : (),
28 exists $args{log} ? (log => \&_log_cb) : (),
29 721 ▶ exists $args{warn} ? (warn => \&_warn_cb) : ());
Branch: 5 branches
BranchTrueFalseTotal
exists $args{'skip'} ? : 721 0 721
exists $args{'with'} ? : 721 0 721
exists $args{'max_loop'} ? : 0 721 721
exists $args{'log'} ? : 0 721 721
exists $args{'warn'} ? : 721 0 721
30  
31 721 return bless {
32 ctx => $ctx,
33 }, $class;
34 }
35  
36 0 ▶sub _log_cb {
Subroutine _log_cb: not called CC=4 SCAR=30.0
37 0 my ($ctx, $action, $stmt, $fmt) = (shift, shift, shift, shift);
38  
39 0 my $parser = $ctx->{parser};
40 0 ▶ my $flg = $ctx->{skipundef} ? '! ' : '';
Branch: 1 branch
BranchTrueFalseTotal
$ctx->{'skipundef'} ? : 0 0 0
41 0 ▶ if ($ctx->{incall}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ctx->{'incall'}) { } 0 0 0
elsif ($ctx->{'infunction'}) { } 0 0 0
42 0 $parser->{log}->($flg . "[$ctx->{infunction}] $action $stmt", $fmt, @_);
43 } elsif ($ctx->{infunction}) {
44 0 $parser->{log}->("<$ctx->{infunction}> $action $stmt", $fmt, @_);
45 } else {
46 0 $parser->{log}->($flg . "$action $stmt", $fmt, @_);
47 }
48 }
49  
50 1834 ▶sub _warn_cb {
Subroutine _warn_cb: called CC=4 SCAR=13.9
51 1834 my ($ctx, $action, $stmt, $fmt) = (shift, shift, shift, shift);
52  
53 1834 my $parser = $ctx->{parser};
54 1834 ▶ my $flg = $ctx->{skipundef} ? '! ' : '';
Branch: 1 branch
BranchTrueFalseTotal
$ctx->{'skipundef'} ? : 593 1241 1834
55 1834 ▶ if ($ctx->{incall}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ctx->{'incall'}) { } 95 1739 1834
elsif ($ctx->{'infunction'}) { } 416 1323 1739
56 95 $parser->{warn}->($flg . "[$ctx->{infunction}] $action $stmt", $fmt, @_);
57 } elsif ($ctx->{infunction}) {
58 416 $parser->{warn}->("<$ctx->{infunction}> $action $stmt", $fmt, @_);
59 } else {
60 1323 $parser->{warn}->($flg . "$action $stmt", $fmt, @_);
61 }
62 }
63  
64 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod documented
65 0 my ($self, $line) = @_;
66 0 my $parser = $self->{ctx}{parser};
67 0 my $str = $parser->setstr($line);
68  
69 0 return $self->{ctx}->parse_eval($str);
70 }
71  
72 0 ▶sub exec {
Subroutine exec: not called CC=1 SCAR=6.9
Pod documented
73 0 my ($self, $stmt) = @_;
74  
75 0 return $self->{ctx}->exec_eval($stmt);
76 }
77  
78 721 ▶sub eval {
Subroutine eval: called CC=1 SCAR=0.0
Pod documented
79 721 my ($self, $line) = @_;
80 721 my $parser = $self->{ctx}{parser};
81 721 my $str = $parser->setstr($line);
82  
83 721 my $stmt = $self->{ctx}->parse_eval($str);
84 721 return $self->{ctx}->exec_eval($stmt);
85 }
86  
87 721 ▶sub format {
Subroutine format: called CC=1 SCAR=0.0
Pod documented
88 721 my ($self, $stmt, $fmt) = @_;
89 721 my $parser = $self->{ctx}{parser};
90  
91 721 return $parser->format_stmt($stmt, $fmt);
92 }
93  
94 2 1;
95  
96 __END__
« blib/lib/PHP/Decode/Array.pm ↑ Summary lib/PHP/Decode/Array.pm »