File Coverage

lib/Neo4j/Driver/Type/Point.pm
Criterion Covered Total %
statement 21 21 100.0
branch 6 6 100.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 35 35 100.0


line stmt bran cond sub pod time code
1 20     20   268 use v5.12;
  20         76  
2 20     20   142 use warnings;
  20         57  
  20         1736  
3              
4             package Neo4j::Driver::Type::Point 1.02;
5             # ABSTRACT: Represents a Neo4j spatial point value
6              
7              
8             # For documentation, see Neo4j::Driver::Types.
9              
10              
11 20     20   250 use parent 'Neo4j::Types::Point';
  20         166  
  20         122  
12              
13              
14             sub _parse {
15 2     2   4 my ($self) = @_;
16            
17 2         19 my ($srid, $x, $y, $z) = $self->{'@'} =~ m/^SRID=([0-9]+);POINT(?: Z)? ?\(([-0-9.]+) ([-0-9.]+)(?: ([-0-9.]+))?\)$/;
18            
19 2         6 $self->{srid} = 0 + $srid;
20 2         10 my @coords = (0 + $x, 0 + $y);
21 2 100       5 push @coords, 0 + $z if defined $z;
22 2         4 $self->{coordinates} = \@coords;
23             }
24              
25              
26             sub srid {
27 3     3 1 924 my ($self) = @_;
28 3 100       11 exists $self->{srid} or $self->_parse;
29 3         10 return $self->{srid};
30             }
31              
32              
33             sub coordinates {
34 4     4 1 466 my ($self) = @_;
35 4 100       15 exists $self->{coordinates} or $self->_parse;
36 4         5 return @{$self->{coordinates}};
  4         19  
37             }
38              
39              
40             1;