Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Jun 10, 2024
1 parent 76a94c4 commit 3d12845
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 776 deletions.
9 changes: 1 addition & 8 deletions src/Lists/Currency.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<?php

/**
* Created by PhpStorm.
* User: andrea
* Date: 09/05/18
* Time: 17.35
*/

namespace Webgriffe\LibQuiPago\Lists;

class Currency
{
const EURO_CURRENCY_CODE = 'EUR';
public const EURO_CURRENCY_CODE = 'EUR';
}
31 changes: 13 additions & 18 deletions src/Lists/Language.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<?php
/**
* Created by PhpStorm.
* User: atedeschi
* Date: 16/05/18
* Time: 16.52
*/

namespace Webgriffe\LibQuiPago\Lists;

class Language
{
const LANGUAGE_ITA = 'ITA';
const LANGUAGE_ENG = 'ENG';
const LANGUAGE_SPA = 'SPA';
const LANGUAGE_FRA = 'FRA';
const LANGUAGE_GER = 'GER';
const LANGUAGE_JPG = 'JPG';
const LANGUAGE_CHI = 'CHI';
const LANGUAGE_ARA = 'ARA';
const LANGUAGE_RUS = 'RUS';
const LANGUAGE_POR = 'POR';
public const LANGUAGE_ITA = 'ITA';
public const LANGUAGE_ENG = 'ENG';
public const LANGUAGE_SPA = 'SPA';
public const LANGUAGE_FRA = 'FRA';
public const LANGUAGE_GER = 'GER';
public const LANGUAGE_JPG = 'JPG';
public const LANGUAGE_CHI = 'CHI';
public const LANGUAGE_ARA = 'ARA';
public const LANGUAGE_RUS = 'RUS';
public const LANGUAGE_POR = 'POR';

/**
* Get options in "key-value" format
*
* @return array
* @return array<string, string>
*/
public function getList()
public function getList(): array
{
return [
self::LANGUAGE_ITA => 'Italian',
Expand Down
14 changes: 4 additions & 10 deletions src/Lists/SignatureMethod.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<?php
/**
* Created by PhpStorm.
* User: andrea
* Date: 09/05/18
* Time: 17.54
*/

namespace Webgriffe\LibQuiPago\Lists;

class SignatureMethod
{
const SHA1_METHOD = 'sha1';
const MD5_METHOD = 'md5';
public const SHA1_METHOD = 'sha1';
public const MD5_METHOD = 'md5';

/**
* @return array
* @return array<string, string>
*/
public function getList()
public function getList(): array
{
return [
self::SHA1_METHOD => self::SHA1_METHOD,
Expand Down
21 changes: 3 additions & 18 deletions src/Notification/DefaultHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,10 @@

class DefaultHandler implements Handler
{
/**
* @var Checker
*/
private $checker;
private Checker $checker;

/**
* @var LoggerInterface
*/
private $logger;
private ?LoggerInterface $logger;

/**
* Handler constructor.
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger = null, Checker $checker = null)
{
if (!$checker) {
Expand All @@ -35,22 +25,17 @@ public function __construct(LoggerInterface $logger = null, Checker $checker = n

/**
* Handle notification request
* @param ServerRequestInterface $httpRequest Notify request coming from Quipago
* @param string $secretKey Secret key for MAC calculation
* @param string $macMethod MAC calculation method. It should be 'sha1' or 'md5'
*
* @return Result
* @throws InvalidMacException
*/
public function handle(ServerRequestInterface $httpRequest, $secretKey, $macMethod)
public function handle(ServerRequestInterface $httpRequest, string $secretKey, string $macMethod): Result
{
if ($this->logger) {
$this->logger->debug(sprintf('%s method called', __METHOD__));
$this->logger->debug(sprintf('Secret key: "%s"', $secretKey));
$this->logger->debug(sprintf('Request body: %s', json_encode($httpRequest->getParsedBody())));
$this->logger->debug(sprintf('Request query: %s', json_encode($httpRequest->getQueryParams())));
}

$request = Request::buildFromHttpRequest($httpRequest);
$this->checker->checkSignature($request, $secretKey, $macMethod);

Expand Down
8 changes: 1 addition & 7 deletions src/Notification/Handler.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<?php
/**
* Created by PhpStorm.
* User: kraken
* Date: 10/08/18
* Time: 15.36
*/

namespace Webgriffe\LibQuiPago\Notification;

use Psr\Http\Message\ServerRequestInterface;

interface Handler
{
public function handle(ServerRequestInterface $httpRequest, $secretKey, $macMethod);
public function handle(ServerRequestInterface $httpRequest, string $secretKey, string $macMethod): Result;
}
Loading

0 comments on commit 3d12845

Please sign in to comment.