diff --git a/.github/workflows/pull-request-checks.yaml b/.github/workflows/pull-request-checks.yaml index 0c97a4a..2aba5e1 100644 --- a/.github/workflows/pull-request-checks.yaml +++ b/.github/workflows/pull-request-checks.yaml @@ -30,12 +30,13 @@ jobs: - name: Run Composer linter run: composer validate --strict --no-check-lock + - name: Run PHP unit test suite + run: composer run-script test + - name: Run phpstan run: composer run-script phpstan - name: Run lint PHP run: composer run-script php-lint - # Tests - - name: Run PHP unit test suite - run: composer run-script test + diff --git a/src/Email/MessageOptions.php b/src/Email/MessageOptions.php index 2c5e23b..1844ecc 100644 --- a/src/Email/MessageOptions.php +++ b/src/Email/MessageOptions.php @@ -42,8 +42,12 @@ public function __construct( $this->participants = $participants; } - public function getSubject(): ?string + public function getSubject(): string { + if (!\is_string($this->subject)) { + throw new InvalidArgumentException('Invalid subject'); + } + return $this->subject; } diff --git a/src/Email/Participants.php b/src/Email/Participants.php index 0ee4a79..d6b0c74 100644 --- a/src/Email/Participants.php +++ b/src/Email/Participants.php @@ -59,8 +59,12 @@ public function __construct( $this->bcc = $bcc; } - public function getSender(): ?Address + public function getSender(): Address { + if (!$this->sender instanceof Address) { + throw new InvalidArgumentException('Invalid sender'); + } + return $this->sender; } diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php new file mode 100644 index 0000000..8c3e551 --- /dev/null +++ b/src/Exception/ExceptionInterface.php @@ -0,0 +1,9 @@ +