From 51b0e0216c1418751cd6d3247be66356a347a07f Mon Sep 17 00:00:00 2001 From: jeffreymoelands Date: Fri, 30 Jul 2021 15:59:48 +0200 Subject: [PATCH 1/2] fix for scrutinizer --- src/Email/MessageOptions.php | 6 +++++- src/Email/Participants.php | 6 +++++- src/Exception/ExceptionInterface.php | 9 +++++++++ src/Exception/InvalidArgumentException.php | 11 +++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/Exception/ExceptionInterface.php create mode 100644 src/Exception/InvalidArgumentException.php 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 @@ + Date: Fri, 30 Jul 2021 16:32:42 +0200 Subject: [PATCH 2/2] run tests first --- .github/workflows/pull-request-checks.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 +