Wikibase/Datatype/Value/Globecoordinate.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 75.0% 3 / 4 totaltotal 98.5% 68 / 69 CC 7 SCAR 13.4
CC
7
Cov
100%
BUILD
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.8
« Wikibase/Datatype/Utils.pm ↑ Summary Wikibase/Datatype/Value/Quantity.pm »
1 package Wikibase::Datatype::Value::Globecoordinate;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use Mo qw(build is);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Wikibase::Datatype::Utils qw(check_entity);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 our $VERSION = 0.40;
11  
12 10 extends 'Wikibase::Datatype::Value';
13  
14 10 has altitude => (
15 'is' => 'ro',
16 );
17  
18 10 has globe => (
19 'is' => 'ro',
20 );
21  
22 1 ▶sub latitude {
Subroutine latitude: called CC=1 SCAR=0.0
Pod documented
23 1 my $self = shift;
24  
25 1 return $self->{'value'}->[0];
26 }
27  
28 1 ▶sub longitude {
Subroutine longitude: called CC=1 SCAR=0.0
Pod documented
29 1 my $self = shift;
30  
31 1 return $self->{'value'}->[1];
32 }
33  
34 10 has precision => (
35 'is' => 'ro',
36 );
37  
38 1 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
39 1 return 'globecoordinate';
40 }
41  
42 15 ▶sub BUILD {
Subroutine BUILD: called CC=7 SCAR=19.5
Pod undocumented
43 15 my $self = shift;
44  
45 15 ▶ if (ref $self->{'value'} ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"value"} ne "ARRAY") 1 14 15
46 1 err "Parameter 'value' must be a array.";
47 }
48 14 ▶ if (@{$self->{'value'}} != 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"value"};} != 2) 1 13 14
49 1 err "Parameter 'value' array must have two fields ".
50 "(latitude and longitude).";
51 }
52 13 my ($lat, $lon) = @{$self->{'value'}};
53 13 ▶ if ($lat !~ m/^\-?\d+\.?\d*$/ms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lat =~ /^\-?\d+\.?\d*$/ms) 1 12 13
54 1 err "Parameter 'value' has bad first parameter (latitude).";
55 }
56 12 ▶ if ($lon !~ m/^\-?\d+\.?\d*$/ms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lon =~ /^\-?\d+\.?\d*$/ms) 1 11 12
57 1 err "Parameter 'value' has bad first parameter (longitude).";
58 }
59  
60 11 ▶ if (! defined $self->{'globe'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"globe"}) 10 1 11
61 10 $self->{'globe'} = 'Q2',
62 }
63 11 check_entity($self, 'globe');
64  
65 11 ▶ if (! defined $self->{'precision'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"precision"}) 10 1 11
66 10 $self->{'precision'} = '1e-07',
67 }
68  
69 11 return;
70 }
71  
72 10 1;
73  
74 __END__
« Wikibase/Datatype/Utils.pm ↑ Summary Wikibase/Datatype/Value/Quantity.pm »