Increased MSI to 65%

This commit is contained in:
Alejandro Celaya
2018-11-17 19:23:25 +01:00
parent 6094d17718
commit 79b2a0839f
15 changed files with 227 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Response;
use Fig\Http\Message\StatusCodeInterface as StatusCode;
use Psr\Http\Message\StreamInterface;
use Zend\Diactoros\Response;
use Zend\Diactoros\Stream;
@@ -13,7 +14,7 @@ class PixelResponse extends Response
private const BASE_64_IMAGE = 'R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==';
private const CONTENT_TYPE = 'image/gif';
public function __construct(int $status = 200, array $headers = [])
public function __construct(int $status = StatusCode::STATUS_OK, array $headers = [])
{
$headers['content-type'] = self::CONTENT_TYPE;
parent::__construct($this->createBody(), $status, $headers);

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Response;
use Endroid\QrCode\QrCode;
use Fig\Http\Message\StatusCodeInterface as StatusCode;
use Psr\Http\Message\StreamInterface;
use Zend\Diactoros\Response;
use Zend\Diactoros\Stream;
@@ -12,7 +13,7 @@ class QrCodeResponse extends Response
{
use Response\InjectContentTypeTrait;
public function __construct(QrCode $qrCode, $status = 200, array $headers = [])
public function __construct(QrCode $qrCode, int $status = StatusCode::STATUS_OK, array $headers = [])
{
parent::__construct(
$this->createBody($qrCode),
@@ -21,13 +22,7 @@ class QrCodeResponse extends Response
);
}
/**
* Create the message body.
*
* @param QrCode $qrCode
* @return StreamInterface
*/
private function createBody(QrCode $qrCode)
private function createBody(QrCode $qrCode): StreamInterface
{
$body = new Stream('php://temp', 'wb+');
$body->write($qrCode->get());

View File

@@ -3,6 +3,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Util;
use Fig\Http\Message\StatusCodeInterface as StatusCode;
use finfo;
use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\Response;
@@ -20,7 +21,7 @@ trait ResponseUtilsTrait
private function generateBinaryResponse(string $path, array $extraHeaders = []): ResponseInterface
{
$body = new Stream($path);
return new Response($body, 200, ArrayUtils::merge([
return new Response($body, StatusCode::STATUS_OK, ArrayUtils::merge([
'Content-Type' => (new finfo(FILEINFO_MIME))->file($path),
'Content-Length' => (string) $body->getSize(),
], $extraHeaders));

View File

@@ -9,7 +9,7 @@ use function strlen;
trait StringUtilsTrait
{
private function generateRandomString($length = 10): string
private function generateRandomString(int $length = 10): string
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);