getDataFromZipcode($sender_zipcode); $recipient_zipcode_data = $this->getDataFromZipcode($recipient_zipcode); if (!in_array($recipient_country, ['GR', 'CY']) && !in_array($sender_country, ['GR', 'CY'])) { return false; } if ($sender_country === 'CY' && $recipient_country === 'CY') { return 'internal_cyprus'; } if ($sender_country === 'CY' || $recipient_country === 'CY') { return 'cyprus'; } if ($sender_store == $recipient_zipcode_data['store']) { return 'same_city'; } if ($recipient_zipcode_data['category'] == 'ΝΗΣΙΩΤΙΚΟΣ') { return 'island'; } if ( $recipient_zipcode_data['region'] != '' && $sender_zipcode_data['region'] != '' && $recipient_zipcode_data['region'] == $sender_zipcode_data['region'] ) { return 'region'; } return 'overland'; } private function getDataFromZipcode($recipient_zipcode) { $json = file_get_contents(__DIR__ . '/mapper.json'); $data = json_decode($json, true); return [ 'store' => $data[$recipient_zipcode]['store'] ?? null, 'category' => $data[$recipient_zipcode]['category'] ?? null, 'region' => $data[$recipient_zipcode]['region'] ?? null, ]; } }