@param $postcode

@return Postcode|null
764559
public static function createSector($postcode)
    {
        $matches = [];

        preg_match(self::RxSector, preg_replace('/[^A-Z0-9\s]/', '', strtoupper($postcode)), $matches);

        if (count($matches) !== 8) {
            return null;
        }

        $obj = new self;

        $obj->setPostcodeArea($matches[6]);
        $obj->setPostcodeOutward($matches[5]);
        $obj->setPostcodeSector($matches[7]);

        return $obj;
    }
1208815
protected function classForCode($code)
    {
        if (isset(self::$respClassMap[$code])) {
            return self::$respClassMap[$code];
        }

        return null;
    }
434632
public function lookup($postcode)
    {
        // Mutate the postcode
        $postcode = $this->mutatePostcode($postcode);

        // Sanitize the postcode:
        $coords = $this->getCoordinates($postcode);

        // If empty, we must have no results
        if (empty($coords)) {
            return [];
        }

        // A second call will now retrieve the address
        $address_url  = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . $coords['latitude'] . ',' . $coords['longitude'] . '&sensor=false';

        $address_json = $this->api->fetch($address_url);

        // The correct result is not always the first one, so loop through results here
        foreach ($address_json->results as $current_address) {
            foreach ($current_address->address_components as $component) {
                // If this address_component is a postcode and matches...
                if(array_search('postal_code', $component->types) !== FALSE
                    && $postcode == $this->mutatePostcode($component->long_name)
                ) {
                    $address_data = $current_address->address_components;
                    break 2;
                }
            }
        }

        // If no exact match found, use the first as a closest option
        if (!isset($address_data)
            && !empty($address_json->results)
        ) {
            $address_data = $address_json->results[0]->address_components;
        }

        // If still nothing, return empty array
        if (!isset($address_data)) {
            return [];
        }

        // Initialize all values as empty
        $street_number = '';
        $street        = '';
        $sublocality   = '';
        $town          = '';
        $county        = '';
        $country       = '';

        // Process the return
        foreach ($address_data as $value) {
            if (array_search('street_number', $value->types) !== FALSE) {
                $street_number = $value->long_name;
            } elseif (array_search('route', $value->types) !== FALSE) {
                $street = $value->long_name;
            } elseif (array_search('sublocality', $value->types) !== FALSE) {
                $sublocality = $value->long_name;
            } elseif (array_search('locality', $value->types) !== FALSE) {
                $town = $value->long_name;
            } elseif (array_search('administrative_area_level_2', $value->types) !== FALSE) {
                $county = $value->long_name;
            } elseif (array_search('country', $value->types) !== FALSE) {
                $country = $value->long_name;
            }
        }

        return [
            'postcode'      => $postcode,
            'street_number' => $street_number,
            'street'        => $street,
            'sublocality'   => $sublocality,
            'town'          => $town,
            'county'        => $county,
            'country'       => $country,
            'latitude'      => $coords['latitude'],
            'longitude'     => $coords['longitude']
        ];
    }
144945
public function getAttributeItem( $code )
	{
		$map = $this->_getAttributeMap();

		if( isset( $map[ $code ] ) ) {
			return $map[ $code ];
		}

		return null;
	}
1043591
public function getAuthorizationCode($code)
    {
        $code = $this->collection('code_table')->findOne(array(
            'authorization_code' => $code
        ));
        return is_null($code) ? false : $code;
    }
1328004
public function parseCode($code)
    {
        $segments = (new NamespacedItemResolver)->parseKey($code);

        if (is_null($segments[0])) {
            $segments[0] = '*';
        }

        return $segments;
    }
912034
public function get($code = null)
    {
        try {
            return $this->findFileObject($code)->output('inline', true);
        }
        catch (Exception $ex) {}

        return Response::make(View::make('backend::404'), 404);
    }
985503
public function getCountry($countryCode)
    {
        // accept lowercase country codes
        $countryCode = strtoupper($countryCode);

        $result = current(array_filter($this->countries, function ($country) use ($countryCode) {
            /** @var VATCountry $country */
            return ($country->getCode() == $countryCode || $country->getCountryCode() == $countryCode);
        }));

        return $result != false ? $result : null;
    }
1360815
public function getAccessToken($code)
    {
        $response = $this->getHttpClient()->get($this->getTokenUrl(), [
            'query' => $this->getTokenFields($code),
        ]);

        return $this->parseAccessToken($response->getBody());
    }
1299647
protected function getCodeResponse($statusCode)
    {
        $this->checkParameters();

        /** @var ResponsesInterface $responses */
        $responses = $this->getIntegration()->getFromContainer(ResponsesInterface::class);
        $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();

        return $responses->getResponse($statusCode, $outputMediaType, null, $this->supportedExtensions);
    }
739365
public static function _postcodeArea ($postcode)
	{
		
		$area	= strtoupper (str_replace (' ', '', trim ($postcode)));
		$length	= strlen ($area);

		if ($length == 5)
		{
			$area	= substr ($area, 0, 2);
		}
		else if ($length == 6)
		{
			$area	= substr ($area, 0, 3);
		}
		else if ($length >= 7)
		{
			$area	= substr ($area, 0, 4);
		}
		
		return $area;
		
	}
841416
protected function UserGetGroupIdByCode($code)
    {
        $rsGroups = CGroup::GetList(($by = 'c_sort'), ($order = 'desc'), [
            'STRING_ID' => $code,
        ]);
        if ($ob = $rsGroups->Fetch()) {
            return $ob['ID'];
        } else {
            return null;
        }
    }
700215
public function nearest($postcode)
    {
        $url = '/postcodes/' . rawurlencode($postcode) . '/nearest';
        $request = new Request('GET', $url);

        return $this->httpTransport($request);
    }
737749
public function getAccessTokenResponse($code)
    {
        $postKey = (version_compare(ClientInterface::VERSION, '6') === 1) ? 'form_params' : 'body';

        $response = $this->getHttpClient()->post($this->getTokenUrl(), [
            'headers' => ['Accept' => 'application/json'],
            $postKey => $this->getTokenFields($code),
        ]);

        return json_decode($response->getBody(), true);
    }
660137
public function getAuthorizationCode($code)
    {
        if (isset($this->authorizationCodes[$code])) {
            return $this->authorizationCodes[$code];
        }

        return null;
    }
1139361
public function find($zipcode)
    {
        $this->setZipCode($zipcode)
            ->buildXMLBody()
            ->sendWebServiceRequest()
            ->parseXMLFromResponse();

        if ($this->hasErrorMessage()) {
            return $this->fetchErrorMessage();
        }

        return $this->fetchZipCodeAddress();
    }
1312377
public static function fromIso($code)
    {
        $countryCode = strtoupper($code);
        $table = self::isoCodes();

        if (!array_key_exists($countryCode, $table)) {
            return null;
        }

        return $table[$countryCode];
    }