Skip to content

Instantly share code, notes, and snippets.

@gnugat
Last active August 29, 2015 14:08
Show Gist options
  • Save gnugat/9d258afbeda30c43090b to your computer and use it in GitHub Desktop.
Save gnugat/9d258afbeda30c43090b to your computer and use it in GitHub Desktop.
gnugat/ripozi - HttpHeader
<?php
namespace Gnugat\Ripozi\Service;
class HttpHeader
{
const AUTHORIZATION_HEADER = 'Authorization';
const CONTENT_TYPE = 'Content-Type';
const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded';
/**
* @param array $headers
* @param string $key
* @param string $value
*
* @return array
*/
public function set(array $headers, $key, $value)
{
$headers[$key] = $value;
return $headers;
}
/**
* @param array $headers
* @param string $user
* @param string $password
*
* @return array
*/
public function setBasicAuthorization(array $headers, $user, $password)
{
return $this->set(
$headers,
self::AUTHORIZATION_HEADER,
'Basic '.base64_encode($user.':'.$password)
);
}
/**
* @param array $headers
*
* @return array
*/
public function setFormContentType(array $headers)
{
return $this->set($headers, self::CONTENT_TYPE, self::FORM_CONTENT_TYPE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment