Highlife/Token/Characters.pm

filter: Statementstmt 26.9% 7 / 26 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 0.0% 0 / 2 totaltotal 21.9% 9 / 41 CC 6 SCAR 32.5
CC
6
Cov
21%
match
42.0
new
2.0
_init
2.0
CRAP 25.8
« Highlife/Rule.pm ↑ Summary Highlife/Utils.pm »
1 package Parse::Highlife::Token::Characters;
2  
3 1 ▶use base qw(Parse::Highlife::Token);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Parse::Highlife::Utils qw(params extend_match);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub new
7 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
8 0 my( $class, @args ) = @_;
9 0 my $self = bless Parse::Highlife::Token->new( @args ), $class;
10 0 return $self -> _init( @args );
11 }
12  
13 sub _init
14 0 ▶{
Subroutine _init: not called CC=1 SCAR=6.9
15 0 my( $self, $characters )
16 = params( \@_,
17 -characters => '',
18 );
19 0 $self->{'characters'} = $characters;
20 0 return $self;
21 }
22  
23 sub match
24 0 ▶{
Subroutine match: not called CC=6 SCAR=37.4
Pod undocumented
25 0 my( $self, $string, $offset ) = @_;
26 0 my $c = $offset;
27 0 ▶ while( $c < length $string ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c < length $string) 0 0 0
28 0 my $found = 0;
29 0 foreach my $char (@{$self->{'characters'}}) {
30 0 my $x = substr( $string, $c, 1 );
31 0 ▶ $found = 1 if $char eq $x;
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $x 0 0 0
32 }
33 0 ▶ last unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
34 0 $c++;
35 }
36 0 ▶ if( $c > $offset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c > $offset) 0 0 0
37 return
38 0 extend_match(
39 $string,
40 {
41 'token-classname' => ref $self,
42 'matched-substring' => substr( $string, $offset, $c - $offset ),
43 'first-offset' => $offset,
44 }
45 );
46 }
47 0 return 0;
48 }
49  
50 1 1;
« Highlife/Rule.pm ↑ Summary Highlife/Utils.pm »