Data/OFN/Address.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary Test/Shared/Fixture/Data/OFN/Address/Place.pm »
1 package Data::OFN::Address;
2  
3 109 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 109 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=2.6
7 use Mo qw(build default is);
8 use Mo::utils 0.31 qw(check_length_fix check_regexp check_strings);
9 use Mo::utils::Array qw(check_array_object);
10 use Mo::utils::Number qw(check_positive_natural);
11 use Readonly;
12 use Unicode::UTF8 qw(decode_utf8);
13  
14 Readonly::Array our @HOUSE_NUMBER_TYPES => (
15 decode_utf8('č.p.'),
16 decode_utf8('č.ev.'),
17 );
18  
19 our $VERSION = 0.02;
20  
21 has address_place => (
22 is => 'ro',
23 );
24  
25 has address_place_code => (
26 is => 'ro',
27 );
28  
29 has cadastral_area => (
30 is => 'ro',
31 );
32  
33 has cadastral_area_name => (
34 default => [],
35 is => 'ro',
36 );
37  
38 has conscription_number => (
39 is => 'ro',
40 );
41  
42 has conscription_number_flag => (
43 is => 'ro',
44 );
45  
46 has district => (
47 is => 'ro',
48 );
49  
50 has district_name => (
51 default => [],
52 is => 'ro',
53 );
54  
55 has element_ruian => (
56 is => 'ro',
57 );
58  
59 has house_number => (
60 is => 'ro',
61 );
62  
63 has house_number_type => (
64 is => 'ro',
65 );
66  
67 has id => (
68 is => 'ro',
69 );
70  
71 has momc => (
72 is => 'ro',
73 );
74  
75 has momc_name => (
76 default => [],
77 is => 'ro',
78 );
79  
80 has mop => (
81 is => 'ro',
82 );
83  
84 has mop_name => (
85 default => [],
86 is => 'ro',
87 );
88  
89 has municipality => (
90 is => 'ro',
91 );
92  
93 has municipality_name => (
94 default => [],
95 is => 'ro',
96 );
97  
98 has municipality_part => (
99 is => 'ro',
100 );
101  
102 has municipality_part_name => (
103 default => [],
104 is => 'ro',
105 );
106  
107 has psc => (
108 is => 'ro',
109 );
110  
111 has street => (
112 is => 'ro',
113 );
114  
115 has street_name => (
116 default => [],
117 is => 'ro',
118 );
119  
120 has text => (
121 default => [],
122 is => 'ro',
123 );
124  
125 has vusc => (
126 is => 'ro',
127 );
128  
129 has vusc_name => (
130 default => [],
131 is => 'ro',
132 );
133  
134 sub BUILD {
135 my $self = shift;
136  
137 # Check address_place.
138 check_regexp($self, 'address_place',
139 qr{^https://linked\.cuzk\.cz/resource/ruian/adresni-misto/\d+$});
140  
141 # Check address_place_code.
142 check_positive_natural($self, 'address_place_code');
143  
144 # Check cadastral_area.
145 check_regexp($self, 'cadastral_area',
146 qr{^https://linked\.cuzk\.cz/resource/ruian/katastralni-uzemi/\d+$});
147  
148 # Check cadastral_area_name.
149 check_array_object($self, 'cadastral_area_name', 'Data::Text::Simple');
150  
151 # Check conscription_number.
152 check_positive_natural($self, 'conscription_number');
153  
154 # Check conscription_number_flag.
155 if (! defined $self->{'conscription_number'}
156 && defined $self->{'conscription_number_flag'}) {
157  
158 err "Parameter 'conscription_number_flag' is possible with 'conscription_number' parameter only.";
159 }
160  
161 # Check district.
162 check_regexp($self, 'district',
163 qr{^https://linked\.cuzk\.cz/resource/ruian/okres/\d+});
164  
165 # Check district_name.
166 check_array_object($self, 'district_name', 'Data::Text::Simple');
167  
168 # Check element_ruian.
169 check_regexp($self, 'element_ruian',
170 qr{^https://linked\.cuzk\.cz/resource/ruian/parcela/\d+$});
171  
172 # Check house_number.
173 check_positive_natural($self, 'house_number');
174  
175 # Check house_number_type.
176 check_strings($self, 'house_number_type', \@HOUSE_NUMBER_TYPES);
177  
178 # Check id.
179 check_positive_natural($self, 'id');
180  
181 # Check momc.
182 check_regexp($self, 'momc',
183 qr{^https://linked\.cuzk\.cz/resource/ruian/momc/\d+$});
184  
185 # Check momc_name.
186 check_array_object($self, 'momc_name', 'Data::Text::Simple');
187  
188 # Check mop.
189 check_regexp($self, 'mop',
190 qr{^https://linked\.cuzk\.cz/resource/ruian/mop/\d+$});
191  
192 # Check mop_name.
193 check_array_object($self, 'mop_name', 'Data::Text::Simple');
194  
195 # Check municipality.
196 check_regexp($self, 'municipality',
197 qr{^https://linked\.cuzk\.cz/resource/ruian/obec/\d+$});
198  
199 # Check municipality_name.
200 check_array_object($self, 'municipality_name', 'Data::Text::Simple');
201  
202 # Check municipality_part.
203 check_regexp($self, 'municipality_part',
204 qr{^https://linked\.cuzk\.cz/resource/ruian/cast-obce/\d+$});
205  
206 # Check municipality_part_name.
207 check_array_object($self, 'municipality_part_name', 'Data::Text::Simple');
208  
209 # Check psc.
210 check_length_fix($self, 'psc', 5);
211 check_regexp($self, 'psc', qw{^\d+$});
212  
213 # Check street.
214 check_regexp($self, 'street',
215 qr{^https://linked\.cuzk\.cz/resource/ruian/ulice/\d+$});
216  
217 # Check street_name.
218 check_array_object($self, 'street_name', 'Data::Text::Simple');
219  
220 # Check text.
221 check_array_object($self, 'text', 'Data::Text::Simple');
222  
223 # Check vusc.
224 check_regexp($self, 'vusc',
225 qr{^https://linked\.cuzk\.cz/resource/ruian/vusc/\d+$});
226  
227 # Check vusc_name.
228 check_array_object($self, 'vusc_name', 'Data::Text::Simple');
229  
230 return;
231 }
232  
233 1;
234  
235 __END__
↑ Summary Test/Shared/Fixture/Data/OFN/Address/Place.pm »