Leaflet/Base.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 70.0% 7 / 10 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 83.6% 51 / 61 CC 8 SCAR 11.9
CC
8
Cov
87%
stringify_base
5.2
options
4.1
_method_name
2.0
CRAP 3.3
« Leaflet/Rectangle.pm ↑ Summary Leaflet.pm »
1 package Geo::Leaflet::Base;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use base qw{Package::New};
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.04';
8 2 our $PACKAGE = __PACKAGE__;
9  
10 =head1 NAME
11  
12 Geo::Leaflet::Base - Leaflet base object
13  
14 =head1 SYNOPSIS
15  
16 use Geo::Leaflet;
17 my $map = Geo::Leaflet->new;
18  
19 =head1 DESCRIPTION
20  
21 This package provides a base package for L<Geo::Leaflet> map objects.
22  
23 =head1 CONSTRUCTORS
24  
25 =head2 new
26
27 =head1 PROPERTIES
28  
29 =head2 options
30  
31 =cut
32  
33 6 ▶sub options {
Subroutine options: called CC=4 SCAR=14.1
Pod documented
34 6 my $self = shift;
35 6 ▶ $self->{'options'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 6 6
36 6 ▶ $self->{'options'} = {} unless $self->{'options'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"options"} 1 5 6
37 6 ▶ die("Error: options must be a hash") unless ref($self->{'options'}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"options"} eq "HASH" 0 6 6
38 6 return $self->{'options'};
39 }
40  
41 =head1 METHODS
42  
43 =head2 stringify_base
44  
45 =cut
46  
47 0 ▶sub _method_name {die};
Subroutine _method_name: not called CC=1 SCAR=6.9
48  
49 3 ▶sub stringify_base {
Subroutine stringify_base: called CC=5 SCAR=16.4
Pod documented
50 3 my $self = shift;
51 3 my $value = shift;
52 #const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
53 # maxZoom: 19,
54 # attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
55 # }).addTo(map);
56 #
57 #const circle = L.circle([51.508, -0.11], {
58 # color: 'red',
59 # fillColor: '#f03',
60 # fillOpacity: 0.5,
61 # radius: 500
62 # }).addTo(map);
63 3 my $addmap = '.addTo(map)';
64 3 ▶ my $popup = $self->can('popup') && $self->popup ? sprintf('.bindPopup(%s)', $self->JSON->encode($self->popup)) : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->can('popup') && $self->popup ? : 2 1 3
Condition66%2/3
$self->can("popup") and $self->popup
!ll&&!rl&&r
102
MC/DC50%1/2
$self->can("popup") and $self->popup
$self->can("popup") $self->popup
Truth table66%2/3
A and B
A= $self->can("popup")B= $self->popup
ABresult
0X0
100
111
65 3 ▶ my $tooltip = $self->can('tooltip') && $self->tooltip ? sprintf('.bindTooltip(%s)', $self->JSON->encode($self->tooltip)) : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->can('tooltip') && $self->tooltip ? : 0 3 3
Condition66%2/3
$self->can("tooltip") and $self->tooltip
!ll&&!rl&&r
120
MC/DC0%0/2
$self->can("tooltip") and $self->tooltip
$self->can("tooltip") $self->tooltip
Truth table66%2/3
A and B
A= $self->can("tooltip")B= $self->tooltip
ABresult
0X0
100
111
66 3 return sprintf(q{L.%s(%s, %s)%s%s%s;},
67 $self->_method_name,
68 $self->JSON->encode($value),
69 $self->JSON->encode($self->options),
70 $addmap,
71 $popup,
72 $tooltip,
73 );
74 }
75  
76 =head2 JSON
77  
78 =cut
79  
80 10 ▶sub JSON {
Subroutine JSON: called CC=1 SCAR=0.0
Pod documented
81 10 my $self = shift;
82 10 $self->{'JSON'} = JSON::XS->new->allow_nonref;
83 10 return $self->{'JSON'};
84 }
85  
86 =head1 SEE ALSO
87  
88 =head1 AUTHOR
89  
90 Michael R. Davis
91  
92 =head1 COPYRIGHT AND LICENSE
93  
94 Copyright (C) 2024 by Michael R. Davis
95  
96 MIT LICENSE
97  
98 =cut
99  
100 2 1;
« Leaflet/Rectangle.pm ↑ Summary Leaflet.pm »