File Coverage

blib/lib/STIX/Location.pm
Criterion Covered Total %
statement 35 35 100.0
branch n/a
condition n/a
subroutine 12 12 100.0
pod n/a
total 47 47 100.0


line stmt bran cond sub pod time code
1             package STIX::Location;
2              
3 24     24   588 use 5.010001;
  24         124  
4 24     24   149 use strict;
  24         54  
  24         807  
5 24     24   120 use warnings;
  24         50  
  24         1515  
6 24     24   155 use utf8;
  24         45  
  24         197  
7              
8 24     24   1048 use STIX::Common::OpenVocabulary;
  24         76  
  24         1204  
9 24     24   146 use Types::Standard qw(Str Num Enum);
  24         56  
  24         271  
10              
11 24     24   90322 use Moo;
  24         60  
  24         209  
12 24     24   11305 use namespace::autoclean;
  24         61  
  24         300  
13              
14             extends 'STIX::Common::Properties';
15              
16 24         2919 use constant SCHEMA =>
17 24     24   2992 'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/location.json';
  24         58  
18              
19 24         2017 use constant PROPERTIES => (
20             qw(type spec_version id created modified),
21             qw(created_by_ref revoked labels confidence lang external_references object_marking_refs granular_markings extensions),
22             qw(name description latitude longitude precision region country administrative_area city street_address postal_code)
23 24     24   163 );
  24         55  
24              
25 24     24   146 use constant STIX_OBJECT => 'SDO';
  24         77  
  24         1411  
26 24     24   143 use constant STIX_OBJECT_TYPE => 'location';
  24         53  
  24         6774  
27              
28             has name => (is => 'rw', isa => Str);
29             has description => (is => 'rw', isa => Str);
30             has latitude => (is => 'rw', isa => Num);
31             has longitude => (is => 'rw', isa => Num);
32             has precision => (is => 'rw', isa => Num);
33             has region => (is => 'rw', isa => Enum [STIX::Common::OpenVocabulary->REGION()]);
34             has country => (is => 'rw', isa => Str);
35             has administrative_area => (is => 'rw', isa => Str);
36             has city => (is => 'rw', isa => Str);
37             has street_address => (is => 'rw', isa => Str);
38             has postal_code => (is => 'rw', isa => Str);
39              
40             1;
41              
42              
43             =encoding utf-8
44              
45             =head1 NAME
46              
47             STIX::Location - STIX Domain Object (SDO) - Location
48              
49             =head1 SYNOPSIS
50              
51             use STIX::Location;
52              
53             my $location = STIX::Location->new();
54              
55              
56             =head1 DESCRIPTION
57              
58             A Location represents a geographic location. The location may be described
59             as any, some or all of the following: region (e.g., North America), civic
60             address (e.g. New York, US), latitude and longitude.
61              
62              
63             =head2 METHODS
64              
65             L inherits all methods from L
66             and implements the following new ones.
67              
68             =over
69              
70             =item STIX::Location->new(%properties)
71              
72             Create a new instance of L.
73              
74             =item $location->administrative_area
75              
76             The state, province, or other sub-national administrative area that this
77             Location describes.
78              
79             =item $location->city
80              
81             The city that this Location describes.
82              
83             =item $location->country
84              
85             The country that this Location describes.
86              
87             =item $location->description
88              
89             A textual description of the Location.
90              
91             =item $location->id
92              
93             =item $location->latitude
94              
95             The latitude of the Location in decimal degrees.
96              
97             =item $location->longitude
98              
99             The longitude of the Location in decimal degrees.
100              
101             =item $location->name
102              
103             A name used to identify the Location.
104              
105             =item $location->postal_code
106              
107             The postal code for this Location.
108              
109             =item $location->precision
110              
111             Defines the precision of the coordinates specified by the latitude and
112             longitude properties, measured in meters.
113              
114             =item $location->region
115              
116             The region that this Location describes. (See C in L)
117              
118             =item $location->street_address
119              
120             The street address that this Location describes.
121              
122             =item $location->type
123              
124             The type of this object, which MUST be the literal C.
125              
126             =back
127              
128              
129             =head2 HELPERS
130              
131             =over
132              
133             =item $location->TO_JSON
134              
135             Encode the object in JSON.
136              
137             =item $location->to_hash
138              
139             Return the object HASH.
140              
141             =item $location->to_string
142              
143             Encode the object in JSON.
144              
145             =item $location->validate
146              
147             Validate the object using JSON Schema (see L).
148              
149             =back
150              
151              
152             =head1 SUPPORT
153              
154             =head2 Bugs / Feature Requests
155              
156             Please report any bugs or feature requests through the issue tracker
157             at L.
158             You will be notified automatically of any progress on your issue.
159              
160             =head2 Source Code
161              
162             This is open source software. The code repository is available for
163             public review and contribution under the terms of the license.
164              
165             L
166              
167             git clone https://github.com/giterlizzi/perl-STIX.git
168              
169              
170             =head1 AUTHOR
171              
172             =over 4
173              
174             =item * Giuseppe Di Terlizzi
175              
176             =back
177              
178              
179             =head1 LICENSE AND COPYRIGHT
180              
181             This software is copyright (c) 2024 by Giuseppe Di Terlizzi.
182              
183             This is free software; you can redistribute it and/or modify it under
184             the same terms as the Perl 5 programming language system itself.
185              
186             =cut