| 1 | package Geo::Postcodes::NO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | ▶ | use Geo::Postcodes::NO::Check (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 17 | our $VERSION = '1.00'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | our $SOURCE_URL = 'https://www.bring.no/postnummerregister-ansi.txt'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 17 | our $DATA_VALID_FROM = '2026-10-01'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | our $DATA_FILE = 'postnummerregister-ansi.txt'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 17 | our $DATA_ENV = 'GEO_POSTCODES_NO_DATA'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | our $DATA_ENCODING = 'cp1252'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 17 | our $DATA_ENCODING_ENV = 'GEO_POSTCODES_NO_ENCODING'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 17 | my @VALID_FIELDS = qw(postcode location borough borough_number county type type_verbose); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 17 | my %VALID_FIELD = map { $_ => 1 } @VALID_FIELDS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 17 | my %COUNTY = %{ Geo::Postcodes::NO::Check::county_table() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 17 | my %BRING_CATEGORY_TO_TYPE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | G => 'ST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | P => 'BX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | B => 'STBX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | S => 'SX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 17 | my %TYPE_DESC = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | BX => 'Postboks', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ST => 'Gateadresse', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | SX => 'Serviceboks', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | IO => 'Kunde med eget postnummer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | STBX => 'Både gateadresse og postboks', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | MU => 'Flere bruksområder (felles)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | PP => 'Porto betalt av mottaker', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | PN => 'Stedsnavn', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 17 | my %TYPE_DESC_EN = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | BX => 'Post Office box', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ST => 'Street address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | SX => 'Service box', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | IO => 'Individual owner', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | STBX => 'Street Address and Post Office box', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | MU => 'Multiple usage', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | PP => 'Porto Paye receiver', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | PN => 'Place name', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 17 | my %LEGAL_MODE = map { $_ => 1 } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'and', 'and not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 'nand', 'nand not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 'oldnand', 'oldnand not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'nor', 'nor not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 'or', 'or not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 'xnor', 'xnor not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'xor', 'xor not', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 17 | my %LEGAL_INITIAL_MODE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | %LEGAL_MODE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | all => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | none => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | not => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | one => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 17 | my (%LOCATION, %BOROUGH_NUMBER, %BOROUGH, %TYPE, %BRING_CATEGORY); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 17 | my ($LOADED_DATA_FILE, $LOADED_DATA_ENCODING, $LOADED_FROM_ENV); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 17 | _load_data(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1089 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my ($class, $postcode) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return unless valid($postcode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | return bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | postcode => $postcode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | location => location_of($postcode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | borough_number => borough_number_of($postcode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | borough => borough_of($postcode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | county => county_of($postcode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | type => type_of($postcode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1086 | ▶ | sub postcode { return _object_field($_[0], 'postcode') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
postcode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1084 | ▶ | sub location { return _object_field($_[0], 'location') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
location: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1084 | ▶ | sub borough_number { return _object_field($_[0], 'borough_number') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
borough_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1084 | ▶ | sub borough { return _object_field($_[0], 'borough') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
borough: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1084 | ▶ | sub county { return _object_field($_[0], 'county') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
county: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1086 | ▶ | sub type { return _object_field($_[0], 'type') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1084 | ▶ | sub type_verbose { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type_verbose: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1084 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1084 | ▶ | return unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1084 | return type2verbose($self->{type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | ▶ | sub get_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | return @VALID_FIELDS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 79 | ▶ | sub is_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_field: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 79 | ▶ | shift if @_ > 1 && _looks_like_invocant($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ > 1 and _looks_like_invocant($_[0])
MC/DC50%1/2
@_ > 1 and _looks_like_invocant($_[0])
@_ > 1
_looks_like_invocant($_[0])
Truth table66%2/3
A and B
A= @_ > 1B= _looks_like_invocant($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 79 | my $field = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 79 | ▶ | return 0 unless defined $field; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 79 | ▶ | return $VALID_FIELD{$field} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 6214 | ▶ | sub legal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
legal: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 6214 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 6214 | ▶ | return 0 unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 6214 | ▶ | return $postcode =~ /\A[0-9]{4}\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 6209 | ▶ | sub valid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 6209 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 6209 | ▶ | return 0 unless legal($postcode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 6208 | ▶ | return exists $LOCATION{$postcode} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 123227 | ▶ | sub postcode_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
postcode_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 123227 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 123227 | return $postcode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 11359 | ▶ | sub location_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
location_of: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 11359 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 11359 | ▶ | return unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 11359 | return $LOCATION{$postcode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 28827 | ▶ | sub borough_number_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
borough_number_of: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 28827 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 28827 | ▶ | return unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 28827 | return $BOROUGH_NUMBER{$postcode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 6201 | ▶ | sub borough_number2borough { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
borough_number2borough: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 6201 | my $borough_number = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 6201 | ▶ | return unless defined $borough_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 6201 | return $BOROUGH{$borough_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 6201 | ▶ | sub borough_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
borough_of: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 6201 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 6201 | ▶ | return unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 6201 | my $borough_number = borough_number_of($postcode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 6201 | ▶ | return unless defined $borough_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 6201 | return borough_number2borough($borough_number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 21538 | ▶ | sub county_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
county_of: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 21538 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 21538 | ▶ | return unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 21538 | my $borough_number = borough_number_of($postcode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 21538 | ▶ | return unless defined $borough_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 21538 | return borough_number2county($borough_number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 21538 | ▶ | sub borough_number2county { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
borough_number2county: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 21538 | my $borough_number = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 21538 | ▶ | return unless defined $borough_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 21538 | ▶ | return unless exists $BOROUGH{$borough_number}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 21538 | my ($county_number) = $borough_number =~ /\A([0-9]{2})/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 21538 | ▶ | return unless defined $county_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 21538 | return $COUNTY{$county_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 64414 | ▶ | sub type_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type_of: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 64414 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 64414 | ▶ | return unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 64414 | return $TYPE{$postcode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5114 | ▶ | sub type_verbose_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type_verbose_of: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 5114 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5114 | ▶ | return unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5114 | my $type = type_of($postcode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5114 | ▶ | return unless defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5114 | return type2verbose($type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6199 | ▶ | sub type2verbose { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type2verbose: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 6199 | ▶ | shift if @_ > 1 && _looks_like_invocant($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ > 1 and _looks_like_invocant($_[0])
MC/DC0%0/2
@_ > 1 and _looks_like_invocant($_[0])
@_ > 1
_looks_like_invocant($_[0])
Truth table33%1/3
A and B
A= @_ > 1B= _looks_like_invocant($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 6199 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 6199 | ▶ | return unless defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 6199 | return $TYPE_DESC{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 3 | ▶ | sub type2verbose_english { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type2verbose_english: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | ▶ | shift if @_ > 1 && _looks_like_invocant($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ > 1 and _looks_like_invocant($_[0])
MC/DC0%0/2
@_ > 1 and _looks_like_invocant($_[0])
@_ > 1
_looks_like_invocant($_[0])
Truth table33%1/3
A and B
A= @_ > 1B= _looks_like_invocant($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | ▶ | return unless defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | return $TYPE_DESC_EN{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | sub get_types { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | return sort keys %TYPE_DESC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 41 | ▶ | sub get_postcodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_postcodes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 41 | return keys %LOCATION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | sub bring_category_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bring_category_of: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my $postcode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | return unless defined $postcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | return $BRING_CATEGORY{$postcode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub source_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source_url: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return $SOURCE_URL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3 | ▶ | sub data_valid_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_valid_from: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | ▶ | return if $LOADED_FROM_ENV; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | return $DATA_VALID_FROM; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 7 | ▶ | sub data_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_file: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 7 | ▶ | return defined $LOADED_DATA_FILE ? $LOADED_DATA_FILE : _data_path(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | sub data_encoding { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_encoding: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | ▶ | shift if @_ && _looks_like_invocant($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and _looks_like_invocant($_[0])
MC/DC0%0/2
@_ and _looks_like_invocant($_[0])
@_
_looks_like_invocant($_[0])
Truth table33%1/3
A and B
A= @_B= _looks_like_invocant($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | return $LOADED_DATA_ENCODING if defined $LOADED_DATA_ENCODING; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | return _data_encoding(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 27 | ▶ | sub is_legal_selectionmode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_legal_selectionmode: called CC=5 SCAR=17.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 27 | ▶ | shift if @_ > 1 && _looks_like_invocant($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ > 1 and _looks_like_invocant($_[0])
MC/DC0%0/2
@_ > 1 and _looks_like_invocant($_[0])
@_ > 1
_looks_like_invocant($_[0])
Truth table33%1/3
A and B
A= @_ > 1B= _looks_like_invocant($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 27 | my $mode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 27 | ▶ | return 0 unless defined $mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 27 | ▶ | return $LEGAL_MODE{$mode} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 39 | ▶ | sub is_legal_initial_selectionmode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_legal_initial_selectionmode: called CC=5 SCAR=17.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 39 | ▶ | shift if @_ > 1 && _looks_like_invocant($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ > 1 and _looks_like_invocant($_[0])
MC/DC0%0/2
@_ > 1 and _looks_like_invocant($_[0])
@_ > 1
_looks_like_invocant($_[0])
Truth table33%1/3
A and B
A= @_ > 1B= _looks_like_invocant($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 39 | my $mode = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 39 | ▶ | return 0 unless defined $mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 39 | ▶ | return $LEGAL_INITIAL_MODE{$mode} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | ▶ | sub get_selectionmodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_selectionmodes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | return sort keys %LEGAL_MODE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | ▶ | sub get_initial_selectionmodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_initial_selectionmodes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | return sort keys %LEGAL_INITIAL_MODE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | ▶ | sub verify_selectionlist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_selectionlist: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | ▶ | shift if @_ && _looks_like_invocant($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and _looks_like_invocant($_[0])
MC/DC0%0/2
@_ and _looks_like_invocant($_[0])
@_
_looks_like_invocant($_[0])
Truth table66%2/3
A and B
A= @_B= _looks_like_invocant($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | return _verify_selectionlist(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 3 | ▶ | sub selection_loop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
selection_loop: called CC=5 SCAR=17.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | my $objects_requested = _shift_class_invocant(\@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | my $procedure = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | ▶ | return 0 unless $procedure && ref $procedure eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$procedure and ref $procedure eq "CODE"
MC/DC0%0/2
$procedure and ref $procedure eq "CODE"
$procedure
ref $procedure eq "CODE"
Truth table33%1/3
A and B
A= $procedureB= ref $procedure eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | my @postcodes = _selection($objects_requested, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | ▶ | return 0 unless @postcodes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | for my $postcode (@postcodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 635 | $procedure->($postcode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 35 | ▶ | sub selection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
selection: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 35 | my $objects_requested = _shift_class_invocant(\@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 35 | return _selection($objects_requested, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 5 | ▶ | sub _verify_selectionlist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verify_selectionlist: called CC=28 SCAR=53.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | my $status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | my @verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | ▶ | return (0, 'No arguments') unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 4 | ▶ | if (is_legal_initial_selectionmode($args[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $mode = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if (@args && defined $args[0] && $args[0] eq 'not' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
@args and defined $args[0] and $args[0] eq "not" and is_legal_initial_selectionmode("$mode $args[0]")
@args and defined $args[0] and $args[0] eq "not"
@args and defined $args[0]
MC/DC0%0/4
@args and defined $args[0] and $args[0] eq "not" and is_legal_initial_selectionmode("$mode $args[0]")
@args
defined $args[0]
$args[0] eq "not"
is_legal_initial_selectionmode("$mode $args[0]")
Truth table0%0/5
A and B and C and D
A= @argsB= defined $args[0]C= $args[0] eq "not"D= is_legal_initial_selectionmode("$mode $args[0]")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | && is_legal_initial_selectionmode("$mode $args[0]")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $mode .= ' ' . shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | push @out, $mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | push @verbose, "Mode: '$mode' - ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | return (1, @out) if $mode eq 'all' || $mode eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mode eq "all" or $mode eq "none"
MC/DC0%0/2
$mode eq "all" or $mode eq "none"
$mode eq "all"
$mode eq "none"
Truth table0%0/3
A or B
A= $mode eq "all"B= $mode eq "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | return (1, @out) if $mode eq 'one' && @args == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mode eq "one" and @args == 0
MC/DC0%0/2
$mode eq "one" and @args == 0
$mode eq "one"
@args == 0
Truth table0%0/3
A and B
A= $mode eq "one"B= @args == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | return (0, @verbose, 'Missing method/value pair - not ok') unless @args >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 4 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 10 | my $argument = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 10 | ▶ | if (is_field($argument)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 6 | push @out, $argument; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 6 | push @verbose, "Field: '$argument' - ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 6 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 6 | $argument = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 6 | push @out, $argument; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 6 | push @verbose, "String: '$argument' - ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | push @verbose, 'Missing string - not ok'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | elsif (is_legal_selectionmode($argument)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | ▶ | if (@args && defined $args[0] && $args[0] eq 'not' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
@args and defined $args[0] and $args[0] eq "not" and is_legal_selectionmode("$argument $args[0]")
@args and defined $args[0] and $args[0] eq "not"
@args and defined $args[0]
MC/DC0%0/4
@args and defined $args[0] and $args[0] eq "not" and is_legal_selectionmode("$argument $args[0]")
@args
defined $args[0]
$args[0] eq "not"
is_legal_selectionmode("$argument $args[0]")
Truth table20%1/5
A and B and C and D
A= @argsB= defined $args[0]C= $args[0] eq "not"D= is_legal_selectionmode("$argument $args[0]")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | && is_legal_selectionmode("$argument $args[0]")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $argument .= ' ' . shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | push @out, $argument; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 3 | push @verbose, "Mode: '$argument' - ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 3 | ▶ | unless (@args >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | push @verbose, 'Missing method/value pair - not ok'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ▶ | elsif (defined $argument && $argument eq 'procedure') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $argument and $argument eq "procedure"
MC/DC0%0/2
defined $argument and $argument eq "procedure"
defined $argument
$argument eq "procedure"
Truth table33%1/3
A and B
A= defined $argumentB= $argument eq "procedure"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | push @out, $argument; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | push @verbose, "Field: 'procedure' - ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $procedure = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if (ref $procedure eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if (_valid_procedure_pointer($procedure)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | push @out, $procedure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | push @verbose, "Procedure pointer: '$procedure' - ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | push @verbose, "No such procedure: '$procedure' - not ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my $shown = defined $procedure ? $procedure : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | push @verbose, "Not a procedure pointer: '$shown' - not ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | ▶ | my $shown = defined $argument ? $argument : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | push @verbose, "Illegal argument: '$shown' - not ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | $status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 4 | ▶ | return (1, @out) if $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | return (0, @verbose); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 38 | ▶ | sub _selection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_selection: called CC=30 SCAR=39.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 38 | my ($objects_requested, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 38 | ▶ | if (@args && defined $args[0] && $args[0] eq 'all') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@args and defined $args[0] and $args[0] eq "all"
@args and defined $args[0]
MC/DC33%1/3
@args and defined $args[0] and $args[0] eq "all"
@args
defined $args[0]
$args[0] eq "all"
Truth table50%2/4
A and B and C
A= @argsB= defined $args[0]C= $args[0] eq "all"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | my @all = sort(get_postcodes()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | return _maybe_objects($objects_requested, @all); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 37 | ▶ | return if @args && defined $args[0] && $args[0] eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@args and defined $args[0] and $args[0] eq "none"
@args and defined $args[0]
MC/DC33%1/3
@args and defined $args[0] and $args[0] eq "none"
@args
defined $args[0]
$args[0] eq "none"
Truth table50%2/4
A and B and C
A= @argsB= defined $args[0]C= $args[0] eq "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 36 | my $limit = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 36 | ▶ | if (@args && defined $args[0] && $args[0] eq 'one') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@args and defined $args[0] and $args[0] eq "one"
@args and defined $args[0]
MC/DC33%1/3
@args and defined $args[0] and $args[0] eq "one"
@args
defined $args[0]
$args[0] eq "one"
Truth table50%2/4
A and B and C
A= @argsB= defined $args[0]C= $args[0] eq "one"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | $limit = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 36 | my $mode = 'and'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 36 | my %out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 36 | my @all = get_postcodes(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 36 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 35 | ▶ | if (defined $args[0] && is_legal_initial_selectionmode($args[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $args[0] and is_legal_initial_selectionmode($args[0])
MC/DC50%1/2
defined $args[0] and is_legal_initial_selectionmode($args[0])
defined $args[0]
is_legal_initial_selectionmode($args[0])
Truth table66%2/3
A and B
A= defined $args[0]B= is_legal_initial_selectionmode($args[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | ▶ | if (@args > 1 && defined $args[1] && $args[1] eq 'not' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
@args > 1 and defined $args[1] and $args[1] eq "not" and is_legal_initial_selectionmode("$args[0] $args[1]")
@args > 1 and defined $args[1] and $args[1] eq "not"
@args > 1 and defined $args[1]
MC/DC0%0/4
@args > 1 and defined $args[1] and $args[1] eq "not" and is_legal_initial_selectionmode("$args[0] $args[1]")
@args > 1
defined $args[1]
$args[1] eq "not"
is_legal_initial_selectionmode("$args[0] $args[1]")
Truth table20%1/5
A and B and C and D
A= @args > 1B= defined $args[1]C= $args[1] eq "not"D= is_legal_initial_selectionmode("$args[0] $args[1]")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | && is_legal_initial_selectionmode("$args[0] $args[1]")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $mode = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $mode .= ' ' . shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | $mode = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 35 | ▶ | _apply_first_clause($mode, \%out, \@all, \@args) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 32 | ▶ | $mode = 'and' if $mode eq 'not'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | elsif ($limit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | %out = map { $_ => 1 } @all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 33 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 21 | ▶ | if (defined $args[0] && is_legal_selectionmode($args[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $args[0] and is_legal_selectionmode($args[0])
MC/DC50%1/2
defined $args[0] and is_legal_selectionmode($args[0])
defined $args[0]
is_legal_selectionmode($args[0])
Truth table66%2/3
A and B
A= defined $args[0]B= is_legal_selectionmode($args[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 17 | ▶ | if (@args > 1 && defined $args[1] && $args[1] eq 'not' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
@args > 1 and defined $args[1] and $args[1] eq "not" and is_legal_selectionmode("$args[0] $args[1]")
@args > 1 and defined $args[1] and $args[1] eq "not"
@args > 1 and defined $args[1]
MC/DC0%0/4
@args > 1 and defined $args[1] and $args[1] eq "not" and is_legal_selectionmode("$args[0] $args[1]")
@args > 1
defined $args[1]
$args[1] eq "not"
is_legal_selectionmode("$args[0] $args[1]")
Truth table20%1/5
A and B and C and D
A= @args > 1B= defined $args[1]C= $args[1] eq "not"D= is_legal_selectionmode("$args[0] $args[1]")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | && is_legal_selectionmode("$args[0] $args[1]")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $mode = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $mode .= ' ' . shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 17 | $mode = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 21 | ▶ | _apply_next_clause($mode, \%out, \@all, \@args) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 33 | ▶ | return unless %out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 30 | my @keys = keys %out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 30 | ▶ | my @out = $limit ? ($keys[int rand @keys]) : sort @keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 30 | return _maybe_objects($objects_requested, @out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 35 | ▶ | sub _apply_first_clause { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_first_clause: called CC=15 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 35 | my ($mode, $out, $all, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 35 | my $field = shift @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 35 | ▶ | return _apply_first_procedure_clause($mode, $out, $all, shift @$args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $field and $field eq "procedure"
MC/DC50%1/2
defined $field and $field eq "procedure"
defined $field
$field eq "procedure"
Truth table66%2/3
A and B
A= defined $fieldB= $field eq "procedure"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | if defined $field && $field eq 'procedure'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 33 | ▶ | return 0 unless defined $field && is_field($field); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $field and is_field($field)
MC/DC0%0/2
defined $field and is_field($field)
defined $field
is_field($field)
Truth table33%1/3
A and B
A= defined $fieldB= is_field($field)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 33 | my $value = shift @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 33 | ▶ | return 0 unless defined $value && length $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $value and length $value
MC/DC0%0/2
defined $value and length $value
defined $value
length $value
Truth table33%1/3
A and B
A= defined $valueB= length $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 33 | my $regex = _selection_regex($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 33 | ▶ | return 0 unless $regex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 31 | my $current_field = _field_reader($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 31 | for my $postcode (@$all) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 158472 | my $current_value = $current_field->($postcode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 158472 | ▶ | next unless defined $current_value && length $current_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $current_value and length $current_value
MC/DC0%0/2
defined $current_value and length $current_value
defined $current_value
length $current_value
Truth table33%1/3
A and B
A= defined $current_valueB= length $current_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 158472 | ▶ | my $match = $current_value =~ $regex ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 158472 | ▶ | if ($mode =~ /not/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 5112 | ▶ | $out->{$postcode}++ unless $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 153360 | ▶ | $out->{$postcode}++ if $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 31 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | ▶ | sub _apply_first_procedure_clause { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_first_procedure_clause: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 2 | my ($mode, $out, $all, $procedure) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 2 | ▶ | return 0 unless _valid_procedure_pointer($procedure); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 2 | for my $postcode (@$all) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 5113 | my $match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 5113 | ▶ | eval { $match = $procedure->($postcode) ? 1 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 5113 | ▶ | return 0 if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 5112 | ▶ | if ($mode =~ /not/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | $out->{$postcode}++ unless $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 5112 | ▶ | $out->{$postcode}++ if $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 21 | ▶ | sub _apply_next_clause { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_next_clause: called CC=52 SCAR=40.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 21 | my ($mode, $out, $all, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 21 | my $field = shift @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 21 | my ($procedure, $current_field, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 21 | ▶ | if (defined $field && $field eq 'procedure') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $field and $field eq "procedure"
MC/DC50%1/2
defined $field and $field eq "procedure"
defined $field
$field eq "procedure"
Truth table66%2/3
A and B
A= defined $fieldB= $field eq "procedure"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 3 | $procedure = shift @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 3 | ▶ | return 0 unless _valid_procedure_pointer($procedure); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 18 | ▶ | return 0 unless defined $field && is_field($field); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $field and is_field($field)
MC/DC0%0/2
defined $field and is_field($field)
defined $field
is_field($field)
Truth table33%1/3
A and B
A= defined $fieldB= is_field($field)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 18 | $current_field = _field_reader($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 18 | $value = shift @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 18 | ▶ | return 0 unless defined $value && length $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $value and length $value
MC/DC0%0/2
defined $value and length $value
defined $value
length $value
Truth table33%1/3
A and B
A= defined $valueB= length $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 18 | $value = _selection_regex($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 18 | ▶ | return 0 unless $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 21 | my @postcodes = _selection_postcodes_for_mode($mode, $out, $all); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 21 | for my $postcode (@postcodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 53687 | my $match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 53687 | ▶ | if ($procedure) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 49 | ▶ | eval { $match = $procedure->($postcode) ? 1 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 49 | ▶ | return 0 if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 53638 | my $current_value = $current_field->($postcode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 53638 | ▶ | next unless defined $current_value && length $current_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $current_value and length $current_value
MC/DC0%0/2
defined $current_value and length $current_value
defined $current_value
length $current_value
Truth table33%1/3
A and B
A= defined $current_valueB= length $current_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 53638 | ▶ | $match = $current_value =~ $value ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 53687 | ▶ | if ($mode eq 'and') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1874 | ▶ | delete $out->{$postcode} unless $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | elsif ($mode eq 'and not') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 653 | ▶ | delete $out->{$postcode} if $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | # 'oldnand'/'oldnand not' reuse this logic; they differ from 'nand' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # only in the iteration set (see _selection_postcodes_for_mode). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ▶ | elsif ($mode eq 'nand' || $mode eq 'oldnand') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mode eq "nand" or $mode eq "oldnand"
MC/DC100%2/2
$mode eq "nand" or $mode eq "oldnand"
$mode eq "nand"
$mode eq "oldnand"
Truth table100%3/3
A or B
A= $mode eq "nand"B= $mode eq "oldnand"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 5132 | ▶ | if ($match && $out->{$postcode}) { delete $out->{$postcode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$match and $out->{$postcode}
MC/DC50%1/2
$match and $out->{$postcode}
$match
$out->{$postcode}
Truth table66%2/3
A and B
A= $matchB= $out->{$postcode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 5124 | else { $out->{$postcode}++ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ▶ | elsif ($mode eq 'nand not' || $mode eq 'oldnand not') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mode eq "nand not" or $mode eq "oldnand not"
MC/DC100%2/2
$mode eq "nand not" or $mode eq "oldnand not"
$mode eq "nand not"
$mode eq "oldnand not"
Truth table100%3/3
A or B
A= $mode eq "nand not"B= $mode eq "oldnand not"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 5132 | ▶ | if (!$match && $out->{$postcode}) { delete $out->{$postcode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $match and $out->{$postcode}
MC/DC100%2/2
not $match and $out->{$postcode}
not $match
$out->{$postcode}
Truth table100%3/3
not(A) and B
A= not $matchB= $out->{$postcode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 5100 | else { $out->{$postcode}++ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | elsif ($mode eq 'or') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 5112 | ▶ | $out->{$postcode}++ if $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | elsif ($mode eq 'or not') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 5112 | ▶ | $out->{$postcode}++ unless $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | elsif ($mode eq 'nor') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 5112 | ▶ | if (!$match && !$out->{$postcode}) { $out->{$postcode}++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$match || $out->{$postcode}
MC/DC100%2/2
$match || $out->{$postcode}
$match
$out->{$postcode}
Truth table100%3/3
A || B
A= $matchB= $out->{$postcode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 20 | ▶ | else { delete $out->{$postcode} if $out->{$postcode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | elsif ($mode eq 'nor not') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | if ($match && !$out->{$postcode}) { $out->{$postcode}++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$match and not $out->{$postcode}
MC/DC0%0/2
$match and not $out->{$postcode}
$match
not $out->{$postcode}
Truth table66%2/3
A and not(B)
A= $matchB= not $out->{$postcode}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 5112 | ▶ | else { delete $out->{$postcode} if $out->{$postcode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | elsif ($mode eq 'xor') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 5112 | ▶ | next unless $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 4 | ▶ | $out->{$postcode} ? delete $out->{$postcode} : $out->{$postcode}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | elsif ($mode eq 'xor not') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 5112 | ▶ | next if $match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 5108 | ▶ | $out->{$postcode} ? delete $out->{$postcode} : $out->{$postcode}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | elsif ($mode eq 'xnor') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 5112 | ▶ | my $boolean = $out->{$postcode} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 5112 | ▶ | $match == $boolean ? $out->{$postcode}++ : delete $out->{$postcode}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | elsif ($mode eq 'xnor not') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 5112 | ▶ | my $boolean = $out->{$postcode} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 5112 | ▶ | $match != $boolean ? $out->{$postcode}++ : delete $out->{$postcode}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 21 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 17 | ▶ | sub _load_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_data: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 17 | ▶ | $LOADED_FROM_ENV = defined $ENV{$DATA_ENV} && length $ENV{$DATA_ENV} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ENV{$Geo::Postcodes::NO::DATA_ENV} and length $ENV{$Geo::Postcodes::NO::DATA_ENV}
MC/DC50%1/2
defined $ENV{$Geo::Postcodes::NO::DATA_ENV} and length $ENV{$Geo::Postcodes::NO::DATA_ENV}
defined $ENV{$Geo::Postcodes::NO::DATA_ENV}
length $ENV{$Geo::Postcodes::NO::DATA_ENV}
Truth table66%2/3
A and B
A= defined $ENV{$Geo::Postcodes::NO::DATA_ENV}B= length $ENV{$Geo::Postcodes::NO::DATA_ENV}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 17 | my $path = _data_path(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 17 | my $encoding = _data_encoding(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 17 | $LOADED_DATA_FILE = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 17 | $LOADED_DATA_ENCODING = $encoding; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 17 | my ($records) = Geo::Postcodes::NO::Check::read_records( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | $encoding, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | county_prefixes => [ keys %COUNTY ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | decode_subject => "postcode data $path", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | line_errors_include_path => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 17 | for my $record (@$records) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 76682 | my ($postcode, $location, $borough_number, $borough, $category) = @$record; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 76682 | my $type = $BRING_CATEGORY_TO_TYPE{$category}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 76682 | $LOCATION{$postcode} = $location; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 76682 | $BOROUGH_NUMBER{$postcode} = $borough_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 76682 | $BOROUGH{$borough_number} = $borough; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 76682 | $TYPE{$postcode} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 76682 | $BRING_CATEGORY{$postcode} = $category; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 17 | ▶ | sub _data_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_path: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 17 | ▶ | return $ENV{$DATA_ENV} if defined $ENV{$DATA_ENV} && length $ENV{$DATA_ENV}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ENV{$Geo::Postcodes::NO::DATA_ENV} and length $ENV{$Geo::Postcodes::NO::DATA_ENV}
MC/DC50%1/2
defined $ENV{$Geo::Postcodes::NO::DATA_ENV} and length $ENV{$Geo::Postcodes::NO::DATA_ENV}
defined $ENV{$Geo::Postcodes::NO::DATA_ENV}
length $ENV{$Geo::Postcodes::NO::DATA_ENV}
Truth table66%2/3
A and B
A= defined $ENV{$Geo::Postcodes::NO::DATA_ENV}B= length $ENV{$Geo::Postcodes::NO::DATA_ENV}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 14 | ▶ | my $module_path = $INC{'Geo/Postcodes/NO.pm'} || __FILE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$INC{'Geo/Postcodes/NO.pm'} || __FILE__
MC/DC0%0/1
$INC{'Geo/Postcodes/NO.pm'} || __FILE__
$INC{'Geo/Postcodes/NO.pm'}
Truth table50%1/2
A
A= $INC{'Geo/Postcodes/NO.pm'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 14 | my (undef, $module_dir) = File::Spec->splitpath($module_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 14 | return File::Spec->catfile($module_dir, 'NO', $DATA_FILE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 17 | ▶ | sub _data_encoding { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data_encoding: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | return $ENV{$DATA_ENCODING_ENV} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 17 | ▶ | if defined $ENV{$DATA_ENCODING_ENV} && length $ENV{$DATA_ENCODING_ENV}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV} and length $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV}
MC/DC50%1/2
defined $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV} and length $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV}
defined $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV}
length $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV}
Truth table66%2/3
A and B
A= defined $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV}B= length $ENV{$Geo::Postcodes::NO::DATA_ENCODING_ENV}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 16 | return $DATA_ENCODING; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 49 | ▶ | sub _field_reader { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_field_reader: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 49 | my $field = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 49 | ▶ | return \&postcode_of if $field eq 'postcode'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 24 | ▶ | return \&location_of if $field eq 'location'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 22 | ▶ | return \&borough_number_of if $field eq 'borough_number'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 22 | ▶ | return \&borough_of if $field eq 'borough'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 21 | ▶ | return \&county_of if $field eq 'county'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 18 | ▶ | return \&type_of if $field eq 'type'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 1 | ▶ | return \&type_verbose_of if $field eq 'type_verbose'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 31 | ▶ | sub _maybe_objects { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_objects: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 31 | my ($objects_requested, @postcodes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 31 | ▶ | return @postcodes unless $objects_requested; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 4 | return map { __PACKAGE__->new($_) } @postcodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 6508 | ▶ | sub _object_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object_field: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 6508 | my ($self, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 6508 | ▶ | return unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 6508 | ▶ | return exists $self->{$field} ? $self->{$field} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 38 | ▶ | sub _shift_class_invocant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shift_class_invocant: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 38 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 38 | ▶ | return 0 unless @$args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 38 | ▶ | return 0 unless defined $args->[0] && !ref $args->[0] && $args->[0] eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $args->[0] and not ref $args->[0] and $args->[0] eq __PACKAGE__
defined $args->[0] and not ref $args->[0]
MC/DC66%2/3
defined $args->[0] and not ref $args->[0] and $args->[0] eq __PACKAGE__
defined $args->[0]
not ref $args->[0]
$args->[0] eq __PACKAGE__
Truth table75%3/4
A and not(B) and C
A= defined $args->[0]B= not ref $args->[0]C= $args->[0] eq __PACKAGE__
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 4 | shift @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 12 | ▶ | sub _looks_like_invocant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_looks_like_invocant: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 12 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 12 | ▶ | return 1 if ref $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 12 | ▶ | return 1 if defined $value && $value =~ /\AGeo::Postcodes::NO(?:\z|::)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and $value =~ /\AGeo::Postcodes::NO(?:\z|::)/
MC/DC50%1/2
defined $value and $value =~ /\AGeo::Postcodes::NO(?:\z|::)/
defined $value
$value =~ /\AGeo::Postcodes::NO(?:\z|::)/
Truth table66%2/3
A and B
A= defined $valueB= $value =~ /\AGeo::Postcodes::NO(?:\z|::)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 4 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 5 | ▶ | sub _valid_procedure_pointer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_procedure_pointer: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 5 | my $ptr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 5 | ▶ | return 0 unless ref $ptr eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 5 | ▶ | return defined &$ptr ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 21 | ▶ | sub _selection_postcodes_for_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_selection_postcodes_for_mode: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 21 | my ($mode, $out, $all) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 21 | ▶ | return keys %$out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$mode eq "and" or $mode eq "and not" or $mode eq "oldnand" or $mode eq "oldnand not"
$mode eq "and" or $mode eq "and not" or $mode eq "oldnand"
$mode eq "and" or $mode eq "and not"
MC/DC100%4/4
$mode eq "and" or $mode eq "and not" or $mode eq "oldnand" or $mode eq "oldnand not"
$mode eq "and"
$mode eq "and not"
$mode eq "oldnand"
$mode eq "oldnand not"
Truth table100%5/5
A or B or C or D
A= $mode eq "and"B= $mode eq "and not"C= $mode eq "oldnand"D= $mode eq "oldnand not"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | if $mode eq 'and' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | || $mode eq 'and not' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | || $mode eq 'oldnand' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | || $mode eq 'oldnand not'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 10 | return @$all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 51 | ▶ | sub _selection_regex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_selection_regex: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 51 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 51 | $value =~ s/%/.*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 51 | my $regex = eval { qr/^$value$/i }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 51 | ▶ | return if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 49 | return $regex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||