diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0e0b2eb..236c203 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -22,10 +22,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ["7.2", "7.3", "7.4", "8.0"]
- composer-flags: ["", "--prefer-lowest"]
- env:
- COMPOSER_ROOT_VERSION: dev-master
+ php: ["8.1", "8.2", "8.3"]
+
steps:
- uses: actions/checkout@v2
@@ -36,7 +34,7 @@ jobs:
coverage: pcov
- name: Install dependencies
- run: composer update ${{ matrix.composer-flags }}
+ run: composer update
- name: Run tests
run: make test
diff --git a/composer.json b/composer.json
index 5f84878..bdf080f 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,7 @@
},
"minimum-stability": "stable",
"require": {
- "php": "^7.2 || ^8.0",
+ "php": "^8.1",
"ext-json": "*",
"ext-iconv": "*",
"php-http/client-implementation": "^1.0",
@@ -31,12 +31,12 @@
},
"require-dev": {
"phpmd/phpmd": "^2.9.1",
- "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0",
+ "phpunit/phpunit": "^10.0",
"php-http/curl-client": "^2.0",
"phpstan/phpstan": "^0.12.64",
"pdepend/pdepend": "^2.5",
"nyholm/psr7": "^1.2",
- "doctrine/coding-standard": "^8.0",
+ "doctrine/coding-standard": "^9.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"egulias/email-validator": "^2.1.23",
"symfony/mailer": "^5.0"
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 3298408..2d00f20 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -28,9 +28,10 @@
-
+
+
-
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index af8f321..d4d005f 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,26 +1,20 @@
-
-
-
-
-
-
-
-
- src/
-
-
-
-
-
- tests/unit
-
-
- tests/integration/
-
-
+
+
+
+
+
+
+
+ tests/unit
+
+
+ tests/integration/
+
+
+
diff --git a/src/MailhogClient.php b/src/MailhogClient.php
index af31ff0..171933c 100644
--- a/src/MailhogClient.php
+++ b/src/MailhogClient.php
@@ -1,5 +1,4 @@
httpClient = $client;
- $this->requestFactory = $requestFactory;
- $this->streamFactory = $streamFactory;
$this->baseUri = rtrim($baseUri, '/');
}
/**
* @return Generator|Message[]
*/
- public function findAllMessages(int $limit = 50)
+ public function findAllMessages(int $limit = 50): Generator
{
$start = 0;
while (true) {
diff --git a/src/Message/Contact.php b/src/Message/Contact.php
index 31deb91..622948c 100644
--- a/src/Message/Contact.php
+++ b/src/Message/Contact.php
@@ -9,20 +9,8 @@
class Contact
{
- /**
- * @var string
- */
- public $emailAddress;
-
- /**
- * @var string|null
- */
- public $name;
-
- public function __construct(string $emailAddress, ?string $name = null)
+ public function __construct(private string $emailAddress, private string |null $name = null)
{
- $this->emailAddress = $emailAddress;
- $this->name = $name;
}
public static function fromString(string $contact): Contact
diff --git a/src/Message/ContactCollection.php b/src/Message/ContactCollection.php
index 0aa6309..9cfb90a 100644
--- a/src/Message/ContactCollection.php
+++ b/src/Message/ContactCollection.php
@@ -18,17 +18,11 @@
*/
class ContactCollection implements Countable, IteratorAggregate
{
- /**
- * @var array|Contact[]
- */
- private $contacts;
-
/**
* @param Contact[] $contacts
*/
- public function __construct(array $contacts)
+ public function __construct(private array $contacts)
{
- $this->contacts = $contacts;
}
public static function fromString(string $contacts): ContactCollection
diff --git a/src/Message/Headers.php b/src/Message/Headers.php
index 67f7931..44a6b30 100644
--- a/src/Message/Headers.php
+++ b/src/Message/Headers.php
@@ -1,5 +1,4 @@
$headers
- */
- private $headers;
-
/**
* @param array $headers
*/
- public function __construct(array $headers)
+ public function __construct(private array $headers)
{
- $this->headers = $headers;
}
/**
@@ -51,7 +44,7 @@ private static function fromRawHeaders(array $rawHeaders): self
$decoded = iconv_mime_decode($header[0]);
- $headers[strtolower($name)] = $decoded ? $decoded : $header[0];
+ $headers[strtolower($name)] = $decoded ?: $header[0];
}
return new Headers($headers);
diff --git a/src/Message/Message.php b/src/Message/Message.php
index 60de815..afd574c 100644
--- a/src/Message/Message.php
+++ b/src/Message/Message.php
@@ -10,64 +10,19 @@
class Message
{
- /**
- * @var string
- */
- public $messageId;
-
- /**
- * @var Contact
- */
- public $sender;
-
- /**
- * @var ContactCollection
- */
- public $recipients;
-
- /**
- * @var ContactCollection
- */
- public $ccRecipients;
-
- /**
- * @var ContactCollection
- */
- public $bccRecipients;
-
- /**
- * @var string
- */
- public $subject;
-
- /**
- * @var string
- */
- public $body;
-
- /**
- * @var Attachment[]
- */
- public $attachments;
-
- /**
- * @var Headers
- */
- public $headers;
-
/**
* @param Attachment[] $attachments
*/
public function __construct(
- string $messageId,
- Contact $sender,
- ContactCollection $recipients,
- ContactCollection $ccRecipients,
- ContactCollection $bccRecipients,
- string $subject,
- string $body,
- array $attachments,
- Headers $headers
+ public string $messageId,
+ public Contact $sender,
+ public ContactCollection $recipients,
+ public ContactCollection $ccRecipients,
+ public ContactCollection $bccRecipients,
+ public string $subject,
+ public string $body,
+ public array $attachments,
+ public Headers $headers
) {
foreach ($attachments as $i => $attachment) {
if (!$attachment instanceof Attachment) {
@@ -81,15 +36,5 @@ public function __construct(
);
}
}
-
- $this->messageId = $messageId;
- $this->sender = $sender;
- $this->recipients = $recipients;
- $this->ccRecipients = $ccRecipients;
- $this->bccRecipients = $bccRecipients;
- $this->subject = $subject;
- $this->body = $body;
- $this->attachments = $attachments;
- $this->headers = $headers;
}
}
diff --git a/src/Message/Mime/Attachment.php b/src/Message/Mime/Attachment.php
index ac2f0e0..4dcdc6c 100644
--- a/src/Message/Mime/Attachment.php
+++ b/src/Message/Mime/Attachment.php
@@ -5,25 +5,10 @@
class Attachment
{
- /**
- * @var string
- */
- public $filename;
-
- /**
- * @var string
- */
- public $mimeType;
-
- /**
- * @var string
- */
- public $content;
-
- public function __construct(string $filename, string $mimeType, string $content)
- {
- $this->filename = $filename;
- $this->mimeType = $mimeType;
- $this->content = $content;
+ public function __construct(
+ public string $filename,
+ public string $mimeType,
+ public string $content,
+ ) {
}
}
diff --git a/src/Message/Mime/MimePart.php b/src/Message/Mime/MimePart.php
index 70c3081..d36b47d 100644
--- a/src/Message/Mime/MimePart.php
+++ b/src/Message/Mime/MimePart.php
@@ -13,43 +13,13 @@
class MimePart
{
- /**
- * @var string
- */
- private $contentType;
-
- /**
- * @var string|null
- */
- private $contentTransferEncoding;
-
- /**
- * @var bool
- */
- private $isAttachment;
-
- /**
- * @var string|null
- */
- private $filename;
-
- /**
- * @var string
- */
- private $body;
-
private function __construct(
- string $contentType,
- ?string $contentTransferEncoding,
- bool $isAttachment,
- ?string $filename,
- string $body
+ private string $contentType,
+ private string |null $contentTransferEncoding,
+ private bool $isAttachment,
+ private string |null $filename,
+ private string $body
) {
- $this->contentType = $contentType;
- $this->contentTransferEncoding = $contentTransferEncoding;
- $this->isAttachment = $isAttachment;
- $this->filename = $filename;
- $this->body = $body;
}
/**
diff --git a/src/Message/Mime/MimePartCollection.php b/src/Message/Mime/MimePartCollection.php
index b2e301a..b3b011e 100644
--- a/src/Message/Mime/MimePartCollection.php
+++ b/src/Message/Mime/MimePartCollection.php
@@ -10,16 +10,10 @@
class MimePartCollection
{
/**
- * @var MimePart[]
+ * @param array $mimeParts
*/
- private $mimeParts;
-
- /**
- * @param MimePart[] $mimeParts
- */
- private function __construct(array $mimeParts)
+ private function __construct(private array $mimeParts)
{
- $this->mimeParts = $mimeParts;
}
/**
diff --git a/src/Specification/AndSpecification.php b/src/Specification/AndSpecification.php
index f160006..fdf7ec9 100644
--- a/src/Specification/AndSpecification.php
+++ b/src/Specification/AndSpecification.php
@@ -10,20 +10,8 @@
final class AndSpecification implements Specification
{
- /**
- * @var Specification
- */
- private $left;
-
- /**
- * @var Specification
- */
- private $right;
-
- public function __construct(Specification $left, Specification $right)
+ public function __construct(private Specification $left, private Specification $right)
{
- $this->left = $left;
- $this->right = $right;
}
public static function all(Specification $specification, Specification ...$other): Specification
diff --git a/src/Specification/AttachmentSpecification.php b/src/Specification/AttachmentSpecification.php
index 05e9286..78cb377 100644
--- a/src/Specification/AttachmentSpecification.php
+++ b/src/Specification/AttachmentSpecification.php
@@ -7,14 +7,8 @@
final class AttachmentSpecification implements Specification
{
- /**
- * @var string
- */
- private $filename;
-
- public function __construct(string $filename)
+ public function __construct(private string $filename)
{
- $this->filename = $filename;
}
public function isSatisfiedBy(Message $message): bool
diff --git a/src/Specification/BodySpecification.php b/src/Specification/BodySpecification.php
index 0003102..48ba99d 100644
--- a/src/Specification/BodySpecification.php
+++ b/src/Specification/BodySpecification.php
@@ -5,22 +5,16 @@
use rpkamp\Mailhog\Message\Message;
-use function strpos;
+use function str_contains;
final class BodySpecification implements Specification
{
- /**
- * @var string
- */
- private $snippet;
-
- public function __construct(string $snippet)
+ public function __construct(private string $snippet)
{
- $this->snippet = $snippet;
}
public function isSatisfiedBy(Message $message): bool
{
- return false !== strpos($message->body, $this->snippet);
+ return str_contains($message->body, $this->snippet);
}
}
diff --git a/src/Specification/HeaderSpecification.php b/src/Specification/HeaderSpecification.php
index 2ad3aa9..8c8fcbd 100644
--- a/src/Specification/HeaderSpecification.php
+++ b/src/Specification/HeaderSpecification.php
@@ -7,20 +7,8 @@
final class HeaderSpecification implements Specification
{
- /**
- * @var string
- */
- private $headerName;
-
- /**
- * @var string|null
- */
- private $headerValue;
-
- public function __construct(string $headerName, ?string $headerValue = null)
+ public function __construct(private string $headerName, private string |null $headerValue = null)
{
- $this->headerName = $headerName;
- $this->headerValue = $headerValue;
}
public function isSatisfiedBy(Message $message): bool
diff --git a/src/Specification/NotSpecification.php b/src/Specification/NotSpecification.php
index b82a39e..44621ce 100644
--- a/src/Specification/NotSpecification.php
+++ b/src/Specification/NotSpecification.php
@@ -7,14 +7,8 @@
final class NotSpecification implements Specification
{
- /**
- * @var Specification
- */
- private $wrapped;
-
- public function __construct(Specification $wrapped)
+ public function __construct(private Specification $wrapped)
{
- $this->wrapped = $wrapped;
}
public function isSatisfiedBy(Message $message): bool
diff --git a/src/Specification/OrSpecification.php b/src/Specification/OrSpecification.php
index 207beca..32cfe68 100644
--- a/src/Specification/OrSpecification.php
+++ b/src/Specification/OrSpecification.php
@@ -10,20 +10,8 @@
final class OrSpecification implements Specification
{
- /**
- * @var Specification
- */
- private $left;
-
- /**
- * @var Specification
- */
- private $right;
-
- public function __construct(Specification $left, Specification $right)
+ public function __construct(private Specification $left, private Specification $right)
{
- $this->left = $left;
- $this->right = $right;
}
public static function any(Specification $specification, Specification ...$other): Specification
diff --git a/src/Specification/RecipientSpecification.php b/src/Specification/RecipientSpecification.php
index 3f3d67a..0ba2610 100644
--- a/src/Specification/RecipientSpecification.php
+++ b/src/Specification/RecipientSpecification.php
@@ -8,14 +8,8 @@
final class RecipientSpecification implements Specification
{
- /**
- * @var Contact
- */
- private $recipient;
-
- public function __construct(Contact $recipient)
+ public function __construct(private Contact $recipient)
{
- $this->recipient = $recipient;
}
public function isSatisfiedBy(Message $message): bool
diff --git a/src/Specification/SenderSpecification.php b/src/Specification/SenderSpecification.php
index 9bb4116..0d6b4bd 100644
--- a/src/Specification/SenderSpecification.php
+++ b/src/Specification/SenderSpecification.php
@@ -8,14 +8,8 @@
final class SenderSpecification implements Specification
{
- /**
- * @var Contact
- */
- private $sender;
-
- public function __construct(Contact $sender)
+ public function __construct(private Contact $sender)
{
- $this->sender = $sender;
}
public function isSatisfiedBy(Message $message): bool
diff --git a/src/Specification/SubjectSpecification.php b/src/Specification/SubjectSpecification.php
index 972e55e..11ad2b2 100644
--- a/src/Specification/SubjectSpecification.php
+++ b/src/Specification/SubjectSpecification.php
@@ -7,14 +7,8 @@
final class SubjectSpecification implements Specification
{
- /**
- * @var string
- */
- private $subject;
-
- public function __construct(string $subject)
+ public function __construct(private string $subject)
{
- $this->subject = $subject;
}
public function isSatisfiedBy(Message $message): bool