Adds an array of headers to the mail object.

@param array An array of headers.
@throws \InvalidArgumentException If the input is not an array, or if
headers are not on the whitelist, or if a header is invalid
(i.e. not a string).
170486
public function addHeaderArray($header_array) {
    if (!is_array($header_array)) {
      $error = sprintf("Input is not an array (Actual type: %s).",
                       gettype($header_array));
      throw new \InvalidArgumentException($error);
    }

    $error = "";
    foreach($header_array as $key => $value) {
      if (!$this->checkValidHeader($key, $value, $error)) {
        throw new \InvalidArgumentException($error);
      }
    }

    foreach($header_array as $key => $value) {
      $new_header = $this->message->addHeader();
      $new_header->setName($key);
      $new_header->setValue($value);
    }
  }
1264564
public function validateScalarArray($array)
    {
        if (!is_array($array)) {
            throw new \InvalidArgumentException(sprintf(
                'Expected array value, got: %s',
                var_export($array, true)
            ));
        }

        foreach ($array as $key => $value) {
            if (false == is_scalar($value)) {
                throw new \InvalidArgumentException(sprintf(
                    'Cannot use an array as a value in a multivalue property. Value was: %s',
                    var_export($array, true)
                ));
            }
        }
    }
218068
public function addOrders( $orders )
	{
		if( !is_array( $orders ) )
			throw new InvalidArgumentException( 'An Array should be given.' );
		foreach( $orders as $column => $direction )
			$this->addOrder( $column, $direction );
	}
151400
public static function isArray($value, $message = null)
    {
        if (!is_array($value)) {
            throw new InvalidArgumentException(sprintf(
                $message ?: 'Expected array, but got %s',
                Helper::typeToString($value)
            ));
        }
    }
1152849
protected function withHeaders(array $headers)
    {
        $this->headers = [];
        foreach ($headers as $key => $value) {
            $this->headers[ strtolower($key) ] = is_array($value)
                ? $value
                : [ $value ];
        }
    }
745941
public static function inArray($value, array $array, $message = null)
    {
        if (!in_array($value, $array)) {
            throw new InvalidArgumentException(sprintf(
                $message ?: 'Value %s is not in array',
                Helper::valueToString($value)
            ));
        }
    }
67676
public function addTranslationArray(array $translations, $language)
    {
        $language = (string) $language;
        if ($language === '') {
            throw new \InvalidArgumentException('$language cannot be empty');
        }

        if (!isset($this->translations[$language])) {
            $this->translations[$language] = [];
        }

        $this->translations[$language] = array_merge(
            $this->translations[$language],
            $translations
        );
    }
778262
protected function validateRecipients(array $recipients)
    {
        if (true == empty($recipients)) {
            throw new \InvalidArgumentException('Recipients list should not be empty');
        }

        foreach ($recipients as $recipient) {
            if (true == is_string($recipient) && $this->isValidMail($recipient)) {
                continue;
            }

            throw new \InvalidArgumentException(sprintf(
                'Given recipients list %s has invalid recipient %s',
                var_export($recipients, true),
                var_export($recipient, true)
            ));
        }
    }
967225
public function addHeaders($headers = array())
    {
        foreach ($headers as $header => $value) {
            $this->addHeader($header, $value);
        }
    }
1223936
public function addHeader($headers)
    {
        foreach ((array) $headers as $header) {
            if (strpos($header, "\n") !== false || strpos($header, "\r") !== false) {
                throw new \InvalidArgumentException('Headers can not contain newline characters for security reasons');
            }
            $this->headers[] = $header;
        }

        return $this;
    }
283114
public function setValues(array $values)
    {
        foreach ($values as $value) {
            if (false === is_scalar($value)) {
                throw InvalidArgumentException::create(
                    'Non-scalar values (such as %s) are not supported.',
                    gettype($value)
                );
            }
        }

        $this->values = $values;
    }
486117
public function setHeader($header) {
        if (is_array($header)) {
            foreach ($header as $v) {
                $this->setHeader($v);
            }
        } else {
            // Remove newlines, they are not allowed in headers.
            $newvalue = preg_replace('/[\r\n]/', '', $header);
            if (!in_array($newvalue, $this->header)) {
                $this->header[] = $newvalue;
            }
        }
    }
1108527
public function addCorsHeaders($headers)
    {
        if (empty($headers) === false) {
            foreach ($headers as $header => $value) {
                app()->response->setHeader($header, $value);
            }
        }
    }
729397
protected static function validateHeaderValue(array $values){
        static $validCache = [];

        foreach($values as $index => $value){
            if(!is_string($value)){
                throw new \InvalidArgumentException(
                    "Header value must be of the type string array, "
                    . gettype($value)
                    . " given at index of {$index}."
                );
            }

            if(!isset($validCache[$value])){
                if(1 !== preg_match(static::REGEX_HEADER_VALUE, $value)){
                    throw new \InvalidArgumentException(
                        "Invalid Header value given at index of {$index}."
                    );
                }
            }

            $validCache[$value]  = true;
        }
    }
1350864
public function setHeader($header, $value)
    {
        if (is_array($value)) {
            $value = implode(';', $value);
        }

        $this->headers[$header] = $value;
    }
964756
public function addHeaders(array $headers = [])
    {
        $this->headers = [];
        if($headers != []) {
            foreach ($headers as $header) {
                $this->headers[] = $header;
            }
        }
        return $this;
    }
980499
public function addHeaders(array $headers)
    {

        foreach ($headers as $key => $value) {
            $header = NULL;
            //Handle Array of String based Headers
            if (is_numeric($key) && strpos($value,":") !== FALSE) {
                $arr = explode(":",$value,2);
                if (count($arr)==2){
                    $header = $arr[0];
                    $value = trim($arr[1]);
                }
            } else {
                $header = $key;
            }
            if ($header !== NULL){
                $this->addHeader($header, $value);
            }
        }
        return $this;
    }