lib/PHP/Decode.pm

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