-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from php-middleware/v3
V3
- Loading branch information
Showing
18 changed files
with
301 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm | ||
|
||
env: | ||
- COMPOSER_FLAGS=--prefer-lowest | ||
- COMPOSER_FLAGS= | ||
|
||
before_script: | ||
|
||
before_install: | ||
- phpenv config-rm xdebug.ini | ||
|
||
install: | ||
- composer update --no-interaction --no-suggest --prefer-dist $COMPOSER_FLAGS | ||
|
||
script: | ||
- vendor/bin/phpunit | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
namespace PhpMiddleware\LogHttpMessages\Formatter; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
final class EmptyMessageFormatter implements ServerRequestFormatter, ResponseFormatter | ||
{ | ||
public function formatServerRequest(ServerRequestInterface $request): FormattedMessage | ||
{ | ||
return FormattedMessage::createEmpty(); | ||
} | ||
|
||
public function formatResponse(ResponseInterface $response): FormattedMessage | ||
{ | ||
return FormattedMessage::createEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
namespace PhpMiddleware\LogHttpMessages\Formatter; | ||
|
||
final class FormattedMessage | ||
{ | ||
private $value; | ||
|
||
public static function fromString(string $value) : self | ||
{ | ||
$instance = new self(); | ||
$instance->value = $value; | ||
|
||
return $instance; | ||
} | ||
|
||
public static function fromArray(array $value) : self | ||
{ | ||
$instance = new self(); | ||
$instance->value = $value; | ||
|
||
return $instance; | ||
} | ||
|
||
public static function createEmpty() : self | ||
{ | ||
return new self(); | ||
} | ||
|
||
/** | ||
* @return array|string|null | ||
*/ | ||
public function getValue() | ||
{ | ||
return $this->value; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
namespace PhpMiddleware\LogHttpMessages\Formatter; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Zend\Diactoros\Response\Serializer; | ||
|
||
final class ResponseFormatter implements HttpMessagesFormatter | ||
interface ResponseFormatter | ||
{ | ||
public function format(ServerRequestInterface $request, ResponseInterface $response) | ||
{ | ||
return Serializer::toString($response); | ||
} | ||
public function formatResponse(ResponseInterface $response) : FormattedMessage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
namespace PhpMiddleware\LogHttpMessages\Formatter; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
interface ServerRequestFormatter | ||
{ | ||
public function formatServerRequest(ServerRequestInterface $request) : FormattedMessage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
namespace PhpMiddleware\LogHttpMessages\Formatter; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Zend\Diactoros\Response\ArraySerializer as ResponseSerializer; | ||
use Zend\Diactoros\Request\ArraySerializer as RequestSerializer; | ||
|
||
final class ZendDiactorosToArrayMessageFormatter implements ServerRequestFormatter, ResponseFormatter | ||
{ | ||
public function formatResponse(ResponseInterface $response): FormattedMessage | ||
{ | ||
$array = ResponseSerializer::toArray($response); | ||
|
||
return FormattedMessage::fromArray($array); | ||
} | ||
|
||
public function formatServerRequest(ServerRequestInterface $request): FormattedMessage | ||
{ | ||
$array = RequestSerializer::toArray($request); | ||
|
||
return FormattedMessage::fromArray($array); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
namespace PhpMiddleware\LogHttpMessages\Formatter; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Zend\Diactoros\Response\Serializer as ResponseSerializer; | ||
use Zend\Diactoros\Request\Serializer as RequestSerializer; | ||
|
||
final class ZendDiactorosToStringMessageFormatter implements ServerRequestFormatter, ResponseFormatter | ||
{ | ||
public function formatResponse(ResponseInterface $response): FormattedMessage | ||
{ | ||
$string = ResponseSerializer::toString($response); | ||
|
||
return FormattedMessage::fromString($string); | ||
} | ||
|
||
public function formatServerRequest(ServerRequestInterface $request): FormattedMessage | ||
{ | ||
$string = RequestSerializer::toString($request); | ||
|
||
return FormattedMessage::fromString($string); | ||
} | ||
} |
Oops, something went wrong.