File Coverage

blib/lib/PPIx/QuoteLike/Token.pm
Criterion Covered Total %
statement 49 57 85.9
branch 10 16 62.5
condition 1 3 33.3
subroutine 19 21 90.4
pod 13 13 100.0
total 92 110 83.6


line stmt bran cond sub pod time code
1             package PPIx::QuoteLike::Token;
2              
3 7     7   1055 use 5.006;
  7         18  
4              
5 7     7   25 use strict;
  7         9  
  7         101  
6 7     7   18 use warnings;
  7         8  
  7         269  
7              
8 7     7   33 use Carp;
  7         23  
  7         347  
9 7     7   25 use PPIx::QuoteLike::Constant qw{ MINIMUM_PERL @CARP_NOT };
  7         9  
  7         584  
10 7         4938 use PPIx::QuoteLike::Utils qw{
11             column_number
12             line_number
13             logical_filename
14             logical_line_number
15             statement
16             visual_column_number
17 7     7   1968 };
  7         30  
18              
19             our $VERSION = '0.024';
20              
21             # Private to this package.
22             sub __new {
23 332     332   257007 my ( $self, %arg ) = @_;
24             defined $arg{content}
25 332 50       546 or croak 'Content required';
26 332   33     894 return bless \%arg, ref $self || $self;
27             }
28              
29             sub content {
30 558     558 1 13642 my ( $self ) = @_;
31 558         1725 return $self->{content};
32             }
33              
34             sub error {
35 46     46 1 111 my ( $self ) = @_;
36 46         183 return $self->{error};
37             }
38              
39             sub location {
40 27     27 1 1107 my ( $self ) = @_;
41 27 50       51 return $self->{location} ? [ @{ $self->{location} } ] : undef;
  27         150  
42             }
43              
44             sub parent {
45 47     47 1 109 my ( $self ) = @_;
46 47         212 return $self->{parent};
47             }
48              
49             sub next_sibling {
50 46     46 1 128 my ( $self ) = @_;
51             $self->{next_sibling}
52 46 100       149 or return;
53 21         45 return $self->{next_sibling};
54             }
55              
56             sub perl_version_introduced {
57 80     80 1 104 my ( $self ) = @_;
58             # TODO use '//' when we can require Perl 5.10.
59             defined $self->{perl_version_introduced}
60 80 100       127 and return $self->{perl_version_introduced};
61 65         114 my $vers = $self->__perl_version_introduced();
62 65 100       113 defined $vers
63             or $vers = MINIMUM_PERL;
64 65         204 return ( $self->{perl_version_introduced} = $vers );
65             }
66              
67             sub __perl_version_introduced {
68 44     44   56 return;
69             }
70              
71             sub perl_version_removed {
72 62     62 1 110 return undef; ## no critic (ProhibitExplicitReturnUndef)
73             }
74              
75             sub previous_sibling {
76 46     46 1 109 my ( $self ) = @_;
77             $self->{previous_sibling}
78 46 100       150 or return;
79 20         35 return $self->{previous_sibling};
80             }
81              
82             sub significant {
83 21     21 1 27 return 1;
84             }
85              
86             sub snext_sibling {
87 0     0 1 0 my ( $sib ) = @_;
88 0         0 while ( $sib = $sib->next_sibling() ) {
89 0 0       0 $sib->significant()
90             and return $sib;
91             }
92 0         0 return;
93             }
94              
95             sub sprevious_sibling {
96 0     0 1 0 my ( $sib ) = @_;
97 0         0 while ( $sib = $sib->previous_sibling() ) {
98 0 0       0 $sib->significant()
99             and return $sib;
100             }
101 0         0 return;
102             }
103              
104             sub top {
105 1     1 1 2 my ( $self ) = @_;
106 1         1 my $kid = $self;
107 1         14 while ( defined ( my $parent = $kid->parent() ) ) {
108 1         3 $kid = $parent;
109             }
110 1         3 return $kid;
111             }
112              
113             sub variables {
114 45     45 1 91 return;
115             }
116              
117             1;
118              
119             __END__