Skip to content

Instantly share code, notes, and snippets.

@hikari-no-yume
Last active August 29, 2015 14:21
Show Gist options
  • Save hikari-no-yume/91bab2265cab5879d534 to your computer and use it in GitHub Desktop.
Save hikari-no-yume/91bab2265cab5879d534 to your computer and use it in GitHub Desktop.
11SR-7: Hypertext Transfer Protocol Message Specification (Working Draft)
<?php
declare(strict_types=1);
namespace Room11\Standard\11SR7\HttpMessage\Interface {
/**
* @description A class to represent a Hypertext Transfer Protocol request
* @link https://standards.room11.php.committee/11sr-7/http-message-specification/working-draft/interface
* @see https://tools.ietf.org/html/rfc7540
* @version Working Draft
* @author Room 11 International Professional PHP: Hypertext Preprocessor Standards Working Group Technical Association
* @copyright Copyright (c) 2010–2015 Collaborators of the Room 11 International Professional PHP: Hypertext Preprocessor Standards Working Group Technical Association
*/
interface HTTPRequestInterface {
/**
* @param $request string The content of the HTTP request
* @return \Room11\Standard\11SR7\HttpMessage\Interface\HTTPRequestInterface
*/
public static function createFromHyperTextTransferProtocolRequestContentString(string $request): self;
/**
* @description Obtains the content of the HTTP request
* @return string The content of the HTTP request
*/
public function getRequestString(): string;
/**
* @description Produces a new HTTP request with a new content
* @param $request The content of the new HTTP request
* @return \Room11\Standard\11SR7\HttpMessage\Interface\HTTPRequestInterface
*/
public function withRequestString(string $request): self;
}
}
namespace Room11\Standard\11SR7\HttpMessage\Implementation {
/**
* @description A class to represent a Hypertext Transfer Protocol request
* @link https://standards.room11.php.committee/11sr-7/http-message-specification/working-draft/implementation
* @see https://tools.ietf.org/html/rfc7540
* @version Working Draft
* @author Room 11 International Professional PHP: Hypertext Preprocessor Standards Working Group Technical Association
* @copyright Copyright (c) 2010–2015 Collaborators of the Room 11 International Professional PHP: Hypertext Preprocessor Standards Working Group Technical Association
*/
class HTTPRequestImplementation implements \Room11\Standard\11SR7\HttpMessage\Interface\HTTPRequestInterface {
/**
* @var string $request The content of the HTTP request
* @internal
*/
private string $request;
/**
* @param $request string The content of the HTTP request
* @return void
* @internal
*/
private function __construct(string $request): void {
$this->request = $request;
}
/**
* @param $request string The content of the HTTP request
* @return \Room11\Standard\11SR7\HttpMessage\Interface\HTTPRequestInterface
*/
public static function createFromHyperTextTransferProtocolRequestContentString(string $request): \Room11\Standard\11SR7\HttpMessage\Interface\HTTPRequestInterface {
return new self($request);
}
/**
* @description Obtains the content of the HTTP request
* @return string The content of the HTTP request
*/
public function getRequestString(): string {
return $this->request;
}
/**
* @description Produces a new HTTP request with a new content
* @param $request The content of the new HTTP request
* @return \Room11\Standard\11SR7\HttpMessage\Interface\HTTPRequestInterface
*/
public function withRequestString(string $request): self {
return new self($request);
}
}
}
@J7mbo
Copy link

J7mbo commented May 21, 2015

Not PSR compliant. cv-pls

@hikari-no-yume
Copy link
Author

@J7mbo This is compliant with the superior 11SR-4 standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment