Set postcode.

@param  string $postcode
@return void
545985
protected function setPostcode(string $postcode): void
    {
        if (! preg_match(self::POSTCODE_FORMAT, $postcode)) {
            throw new InvalidArgumentException('Postcode must match the expected format: ' . self::POSTCODE_FORMAT);
        }

        $this->postcode = $postcode;
    }
951300
public function setStatus($code = 200, $text = '')
    {
        if (empty($code) or !is_numeric($code)) {
            throw new ResponseException('Status codes must be numeric.');
        }

        if (empty($text)) {
            if (!is_int($code)) {
                $code = (int) $code;
            }

            if (isset($this->httpCode[$code])) {
                $text = $this->httpCode[$code];
            } else {
                throw new ResponseException('No status text available. Please check your status code number or supply your own message text.');
            }
        }

        if (strpos(PHP_SAPI, 'cgi') === 0) {
            header('Status: ' . $code . ' ' . $text, true);
        } else {
            $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
            header($protocol . ' ' . $code . ' ' . $text, true, $code);
        }
    }
1163523
public function setStatusCode($code)
    {
        $this->headerBag->setStatusCode($code);
        $this->statusCode = $code;

        return $this;
    }
1292273
public function setBillingAdress(
        $postalCode,
        $street = null,
        $number = null,
        $complement = null,
        $district = null,
        $city = null,
        $state = null,
        $country = null
    ) {

        $param = $postalCode;
        $this->billing = new PagSeguroBilling();
        if (isset($param) and is_array($param)) {
            $this->billing->setAddress(new PagSeguroAddress($param));
        } elseif ($param instanceof PagSeguroAddress) {
            $this->billing->setAddress($param);
        } else {
            $billindAdress = array(
                'postalCode' => $postalCode,
                'street' => $street,
                'number' => $number,
                'complement' => $complement,
                'district' => $district,
                'city' => $city,
                'state' => $state,
                'country' => $country
            );
            
            $this->billing->setAddress(new PagSeguroAddress($billindAdress));
        }
    }
806118
public function setAddress($address)
    {
        if (is_object($address)) {
            $this->address = $address;
        } elseif (is_string($address) || is_array($address)) {
            $this->address = new Address($address);
        }
    }
1154142
private function setPost()
    {
        if ($this->parameters['header']["Content-Type"] == "application/x-www-form-urlencoded") {
            if (isset($_GET)) {
                foreach ($_GET as $k => $v) {
                    $this->log->debug("[ _POST Params ]" . $k . ": " . $v, []);
                    $this->post->$k = $this->setSecurityLevel($v);
                    $this->parameters["post"][$k] = $this->setSecurityLevel($v);
                }
                unset($_GET);
            }
        }

        if (isset($_POST)) {
            foreach ($_POST as $k => $v) {
                if (is_array($v) == true) {
                    $this->log->debug("[ _POST Params ]" . $k . ": " . json_encode($v), []);
                } else {
                    $this->log->debug("[ _POST Params ]" . $k . ": " . $v, []);
                }
                $this->post->$k = $this->setSecurityLevel($v);
                $this->parameters["post"][$k] = $this->setSecurityLevel($v);
            }


            $rawData = file_get_contents("php://input");
            if (isset($rawData)) {
                $this->log->debug("[ POST RawData ] : " . $rawData, []);
                $this->parameters["post"]["raw"] = $rawData;
                $this->post->raw = $rawData;
            }

            unset($_POST);
        }
    }
8847
public function setStatusCode($code = null)
    {
        if (!empty($code)) {
            $this->_statusCode = $code;
            http_response_code($this->_statusCode); // this sends the http status code
        }
    }
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']
        ];
    }
918102
public function setAddress($address)
    {
        if (preg_match(self::ADDRESS_REGEXP, $address)) {
            $this->address = $address;
        } else {
            throw new Exception("Malformed e-mail address: $address");
        }
    }
1371718
public function setCode($code)
    {
        if (!is_scalar($code)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Wrong parameters for %s([int|string $code]); %s given.',
                    __METHOD__,
                    is_object($code) ? get_class($code) : gettype($code)
                ),
                E_ERROR
            );
        }

        $this->code = $code;

        return $this;
    }
1246697
public function setCode($code) {
        $this->code = trim($code);
        $this->codeLength = strlen($this->code);
        return $this;
    }
700215
public function nearest($postcode)
    {
        $url = '/postcodes/' . rawurlencode($postcode) . '/nearest';
        $request = new Request('GET', $url);

        return $this->httpTransport($request);
    }
1014284
public function setPostcode(\Chill\MainBundle\Entity\PostalCode $postcode = null)
    {
        $this->postcode = $postcode;

        return $this;
    }
1338320
public function setWarehouseCode( $code )
	{
		$this->_checkCode( $code );

		if ( $code == $this->getWarehouseCode() ) { return; }

		$this->_values['warehousecode'] = (string) $code;
		$this->setModified();
	}
410799
public function setSupplierCode( $suppliercode )
	{
		if ( $suppliercode == $this->getSupplierCode() ) { return; }

		$this->_values['suppliercode'] = (string) $suppliercode;
		$this->setModified();
	}
1025266
public function validatePostcode($postcode)
    {
        if (!is_string($postcode)) {
            return null;
        }

        if ($postcode) {
            $postcode = self::clean($postcode);
        }

        // add in space
        if (strlen($postcode) >= 5) {
            $postcode = preg_replace('/([0-9][A-Z][A-Z])$/is', ' $1', $postcode, 1);
        }

        // Aware that this is not the official RegExp as the setters define whether the part is valid
        $regularExpression = self::RxComplete;

        $matches = [];
        preg_match($regularExpression, $postcode, $matches);

        $cMatches = count($matches);

        if ($cMatches) {
            if ($cMatches === 2 && $matches[0]) {
                $this->setPostcodeArea($matches[0]);
            }

            if ($cMatches === 4 && $matches[2] && $matches[3]) {
                $this->setPostcodeArea($matches[3]);
                $this->setPostcodeOutward($matches[2]);
            }

            if ($cMatches === 9 &&
                $matches[4] && $matches[5] && $matches[6] && $matches[7] &&
                in_array($matches[6], self::$postcodeAreas, true)
            ) {
                $this->setPostcode(str_replace(' ', '', $matches[4]));
                $this->setPostcodeArea($matches[6]);
                $this->setPostcodeOutward($matches[5]);
                $this->setPostcodeInward($matches[7]);
                $this->setPostcodeSector($matches[8]);
            }
        }

        return $this->getPostcode();
    }
634155
public void setCode(ExprCode code) {
        mCode = code;

        mStartPos = mCode.mStartPos;
        mCurIndex = mStartPos;
    }