Skip to content
Merged
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 .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
Loading