/** * Maps WeFact Whois object to ODR contact format * * @param Whois $whois Whois object * @param mixed $type Contact Type * * @return array */ public function mapWhoisToContact(Whois $whois, $type) { $prefix = $this->_getContactPrefix($type); // Some help-functions, to obtain more formatted data $whois->getParam($prefix, 'StreetName'); // Not only Address, but also StreetName, StreetNumber and StreetNumberAddon are available after calling this function $whois->getParam($prefix, 'CountryCode'); // Phone and faxnumber are split. CountryCode, PhoneNumber and FaxNumber available. CountryCode contains for example '+31'. PhoneNumber contains number without leading zero e.g. '123456789' $legalForm = $this->_getLegalForm($whois, $prefix); $gender = 'NA'; if (in_array(strtoupper($whois->{$prefix . 'Sex'}), array('F', 'M'), true)) { $gender = strtoupper($whois->{$prefix . 'Sex'}) === 'F' ? 'FEMALE' : 'MALE'; } $custs = empty($whois->{$prefix . 'customvalues'}) ? array() : $whois->{$prefix . 'customvalues'}; if (empty($custs) && !empty($whois->{$prefix . 'custom'})) { $custs = $whois->{$prefix . 'custom'}; } $state = empty($whois->{$prefix . 'State'}) ? null : $whois->{$prefix . 'State'}; if ($state === null) { if (isset($custs['state'])) { $state = $custs['state']; } elseif (isset($custs['region'])) { $state = $custs['region']; } } return array('type' => $this->mapContactPrefixToOdr($prefix), 'first_name' => $whois->{$prefix . 'Initials'}, 'last_name' => $whois->{$prefix . 'SurName'}, 'full_name' => trim($whois->{$prefix . 'Initials'} . ' ' . $whois->{$prefix . 'SurName'}), 'initials' => $whois->{$prefix . 'Initials'}, 'state' => $state, 'city' => $whois->{$prefix . 'City'}, 'postal_code' => strtoupper(str_replace(' ', '', $whois->{$prefix . 'ZipCode'})), 'phone' => $whois->{$prefix . 'CountryCode'} . '.' . str_replace(' ', '', $whois->{$prefix . 'PhoneNumber'}), 'email' => $whois->{$prefix . 'EmailAddress'}, 'country' => $whois->{$prefix . 'Country'}, 'language' => 'NL', 'gender' => $gender, 'street' => $whois->{$prefix . 'StreetName'}, 'house_number' => $whois->{$prefix . 'StreetNumber'} . ' ' . $whois->{$prefix . 'StreetNumberAddon'}, 'company_name' => $whois->{$prefix . 'CompanyName'} ?: trim($whois->{$prefix . 'Initials'} . ' ' . $whois->{$prefix . 'SurName'}), 'company_email' => $whois->{$prefix . 'EmailAddress'}, 'company_street' => $whois->{$prefix . 'StreetName'}, 'company_house_number' => $whois->{$prefix . 'StreetNumber'} . ' ' . $whois->{$prefix . 'StreetNumberAddon'}, 'company_postal_code' => strtoupper(str_replace(' ', '', $whois->{$prefix . 'ZipCode'})), 'company_city' => $whois->{$prefix . 'City'}, 'company_phone' => $whois->{$prefix . 'CountryCode'} . '.' . str_replace(' ', '', $whois->{$prefix . 'PhoneNumber'}), 'company_vatin' => $whois->{$prefix . 'TaxNumber'}, 'organization_legal_form' => $legalForm); }