Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.2-cli
FROM php:8.2-cli
LABEL maintainer="neto.joaobatista@gmail.com"

RUN apt -y update && apt -y install zlib1g-dev zip
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"license": "MIT",
"type": "library",
"require": {
"php": ">=7.2",
"php": ">=8.2",
"ext-curl": "*",
"ext-json": "*",
"psr/log": "^1.1",
"psr/log": "^1.1 ||^2.0 || ^3.0",
"monolog/monolog": "*"
},
"require-dev": {
Expand Down
21 changes: 21 additions & 0 deletions src/Rede/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class Authorization
*/
private $tid;

/**
* @var object
*/
private $brand;

/**
* @return string
*/
Expand Down Expand Up @@ -417,4 +422,20 @@ public function setTid($tid)
$this->tid = $tid;
return $this;
}

/**
* @return object
*/
public function getBrand()
{
return $this->brand;
}

/**
* @param object $brand
*/
public function setBrand($brand): void
{
$this->brand = $brand;
}
}
23 changes: 23 additions & 0 deletions src/Rede/Brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class Brand
*/
private $returnMessage;

/**
* @var string
*/
private $authorizationCode;

/**
* @return string
*/
Expand Down Expand Up @@ -78,5 +83,23 @@ public function setReturnMessage(string $returnMessage): Brand
return $this;
}

/**
* @param string $authorizationCode
*
* @return Brand
*/
public function setAuthorizationCode(string $authorizationCode): Brand
{
$this->authorizationCode = $authorizationCode;
return $this;
}

/**
* @return string
*/
public function getAuthorizationCode(): string
{
return $this->authorizationCode;
}

}
2 changes: 1 addition & 1 deletion src/Rede/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function setSessionId($sessionId)
/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$consumer = new stdClass();
$consumer->ip = $this->ip;
Expand Down
29 changes: 29 additions & 0 deletions src/Rede/Exception/RedeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,37 @@

namespace Rede\Exception;

use Rede\Transaction;
use RuntimeException;
use Throwable;

class RedeException extends RuntimeException
{
private ?string $response = null;

private ?Transaction $transaction = null;

public function __construct($message = "", $code = 0, ?Throwable $previous = null, ?string $response = null, ?Transaction $transaction = null)
{
parent::__construct($message, $code, $previous);

$this->response = $response;
$this->transaction = $transaction;
}

/**
* @return string|null
*/
public function getResponse(): ?string
{
return $this->response;
}

/**
* @return Transaction|null
*/
public function getTransaction(): ?Transaction
{
return $this->transaction;
}
}
2 changes: 1 addition & 1 deletion src/Rede/SerializeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait SerializeTrait
/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return array_filter(get_object_vars($this), function ($v) {
return $v !== null;
Expand Down
8 changes: 1 addition & 7 deletions src/Rede/Service/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class AbstractService
* @param Store $store
* @param LoggerInterface|null $logger
*/
public function __construct(Store $store, LoggerInterface $logger = null)
public function __construct(Store $store, ?LoggerInterface $logger = null)
{
$this->store = $store;
$this->logger = $logger;
Expand Down Expand Up @@ -93,10 +93,6 @@ protected function sendRequest($body = '', $method = 'GET')
$userAgent .= sprintf(' %s/%s', $this->platform, $this->platformVersion);
}

if (is_resource($this->curl)) {
curl_close($this->curl);
}

$curlVersion = curl_version();

if (is_array($curlVersion)) {
Expand Down Expand Up @@ -194,8 +190,6 @@ protected function sendRequest($body = '', $method = 'GET')
throw new RuntimeException(sprintf('Curl error[%s]: %s', curl_errno($this->curl), curl_error($this->curl)));
}

curl_close($this->curl);

$this->curl = null;

return $this->parseResponse($response, $httpInfo['http_code']);
Expand Down
6 changes: 4 additions & 2 deletions src/Rede/Service/AbstractTransactionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class AbstractTransactionsService extends AbstractService
* @param Transaction|null $transaction
* @param LoggerInterface|null $logger
*/
public function __construct(Store $store, Transaction $transaction = null, LoggerInterface $logger = null)
public function __construct(Store $store, ?Transaction $transaction = null, ?LoggerInterface $logger = null)
{
parent::__construct($store, $logger);

Expand Down Expand Up @@ -100,7 +100,9 @@ protected function parseResponse($response, $statusCode)
throw new RedeException(
$this->transaction->getReturnMessage(),
$this->transaction->getReturnCode(),
$previous
$previous,
$response,
$this->transaction
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Rede/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Store
* @param string $token
* @param Environment|null $environment if none provided, production will be used.
*/
public function __construct($filiation, $token, Environment $environment = null)
public function __construct($filiation, $token, ?Environment $environment = null)
{
$environment = $environment != null ? $environment : Environment::production();

Expand Down
6 changes: 4 additions & 2 deletions src/Rede/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function capture($capture = true)
* @return array
* @see \JsonSerializable::jsonSerialize()
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$capture = null;

Expand Down Expand Up @@ -446,7 +446,9 @@ public function jsonUnserialize($serialized)
continue;
}

$this->$property = $value;
if (property_exists($this, $property)) {
$this->$property = $value;
}
}

return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Rede/eRede.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class eRede
* @param Store $store
* @param LoggerInterface|null $logger
*/
public function __construct(Store $store, LoggerInterface $logger = null)
public function __construct(Store $store, ?LoggerInterface $logger = null)
{
$this->store = $store;
$this->logger = $logger;
Expand Down