Skip to content

Commit

Permalink
Merge pull request #18 from ivinteractive/main
Browse files Browse the repository at this point in the history
PHP 8.4 support
  • Loading branch information
iv-craig authored Dec 16, 2024
2 parents 9ec4ad5 + e47169e commit a56a9fa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.3]
php: [8.3, 8.4]

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2, 8.3]
php: [8.1, 8.2, 8.3, 8.4]

name: Tests on PHP ${{ matrix.php }} - ${{ matrix.stability }}

Expand Down
34 changes: 20 additions & 14 deletions src/Exceptions/CouldNotSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NotificationChannels\Interfax\Exceptions;

use Exception;
use Throwable;
use NotificationChannels\Interfax\InterfaxMessage;

class CouldNotSendNotification extends Exception
Expand All @@ -13,29 +14,34 @@ class CouldNotSendNotification extends Exception
protected array $responseAttributes;

/**
* @param string $message
* @param int $code
* @param Exception|null $previous
* @param InterfaxMessage $interfaxMessage
* @param array<string, mixed> $responseAttributes
* @param InterfaxMessage $message
* @param array<string, mixed> $responseAttributes
* @param string $exceptionMessage
* @return CouldNotSendNotification
*/
final public function __construct(string $message, int $code, Exception $previous = null, InterfaxMessage $interfaxMessage, array $responseAttributes)
public static function serviceRespondedWithAnError(InterfaxMessage $message, array $responseAttributes, string $exceptionMessage = 'The fax failed to send via InterFAX.')
{
parent::__construct($message, $code, $previous);
$exception = new self($exceptionMessage, $responseAttributes['status'], null);
$exception->setInterfaxMessage($message);
$exception->setResponseAttributes($responseAttributes);

return $exception;
}

/**
* @param InterfaxMessage $interfaxMessage
*/
public function setInterfaxMessage(InterfaxMessage $interfaxMessage): void
{
$this->interfaxMessage = $interfaxMessage;
$this->responseAttributes = $responseAttributes;
}

/**
* @param InterfaxMessage $message
* @param array<string, mixed> $responseAttributes
* @param string $exceptionMessage
* @return CouldNotSendNotification
* @param array<string, mixed> $responseAttributes
*/
public static function serviceRespondedWithAnError(InterfaxMessage $message, array $responseAttributes, string $exceptionMessage = 'The fax failed to send via InterFAX.')
public function setResponseAttributes(array $responseAttributes): void
{
return new static($exceptionMessage, $responseAttributes['status'], null, $message, $responseAttributes);
$this->responseAttributes = $responseAttributes;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/InterfaxFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ class InterfaxFile extends \Interfax\File
/**
* File constructor.
*
* @param \Interfax\Client $client
* @param resource|string $location
* @param array<string, mixed> $params
*
* @throws \InvalidArgumentException
*/
public function __construct(\Interfax\Client $client, $location, $params = [], \Interfax\GenericFactory $factory = null)
public function __construct(\Interfax\Client $client, $location, $params = [], ?\Interfax\GenericFactory $factory = null)
{
if ($chunkSize = config('services.interfax.chunk_size')) {
static::$DEFAULT_CHUNK_SIZE = $chunkSize;
Expand Down

0 comments on commit a56a9fa

Please sign in to comment.