From befd2f0fc98ef9b2dbda9a7bc5b918f40100cd5a Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sun, 9 Apr 2023 14:22:01 +0300 Subject: [PATCH 1/6] - Add pagination to Mailinglist members - Additional check for avoiding possible error --- src/Api/MailingList/Member.php | 20 +++++++++--------- src/Model/EmailValidationV4/Job.php | 32 +++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/Api/MailingList/Member.php b/src/Api/MailingList/Member.php index a3d3b1fc..abe1fcec 100644 --- a/src/Api/MailingList/Member.php +++ b/src/Api/MailingList/Member.php @@ -12,6 +12,7 @@ namespace Mailgun\Api\MailingList; use Mailgun\Api\HttpApi; +use Mailgun\Api\Pagination; use Mailgun\Assert; use Mailgun\Exception\InvalidArgumentException; use Mailgun\Model\MailingList\Member\CreateResponse; @@ -26,6 +27,9 @@ */ class Member extends HttpApi { + + use Pagination; + /** * Returns a paginated list of members of the mailing list. * @@ -79,17 +83,13 @@ public function show(string $list, string $address) /** * Creates (or updates) a member of the mailing list. - * - * @param string $list Address of the mailing list - * @param string $address Address for the member - * @param string $name Name for the member (optional) - * @param array $vars Array of field => value pairs to store additional data - * @param bool $subscribed `true` to add as subscribed (default), `false` as unsubscribed - * @param bool $upsert `true` to update member if present, `false` to raise error in case of a duplicate member (default) - * + * @param string $list Address of the mailing list + * @param string $address Address for the member + * @param string|null $name Name for the member (optional) + * @param array $vars Array of field => value pairs to store additional data + * @param bool $subscribed `true` to add as subscribed (default), `false` as unsubscribed + * @param bool $upsert `true` to update member if present, `false` to raise error in case of a duplicate member (default) * @return CreateResponse - * - * @throws \Exception */ public function create(string $list, string $address, string $name = null, array $vars = [], bool $subscribed = true, bool $upsert = false) { diff --git a/src/Model/EmailValidationV4/Job.php b/src/Model/EmailValidationV4/Job.php index 9e431144..53beb32d 100755 --- a/src/Model/EmailValidationV4/Job.php +++ b/src/Model/EmailValidationV4/Job.php @@ -51,55 +51,83 @@ class Job implements ApiResponse */ private $summary; + /** + * + */ final private function __construct() { } + /** + * @param array $data + * @return static + */ public static function create(array $data): self { $model = new static(); $model->createdAt = isset($data['created_at']) ? (DateTimeImmutable::createFromFormat('U', (string) $data['created_at']) ?: null) : null; - $model->downloadUrl = $data['download_url'] ? JobDownloadUrl::create($data['download_url']) : null; + $model->downloadUrl = isset($data['download_url']) ? JobDownloadUrl::create($data['download_url']) : null; $model->id = $data['id'] ?? null; $model->quantity = $data['quantity'] ?? null; $model->recordsProcessed = $data['records_processed'] ?? null; $model->status = $data['status'] ?? null; - $model->summary = $data['summary'] ? Summary::create($data['summary']) : null; + $model->summary = isset($data['summary']) ? Summary::create($data['summary']) : null; return $model; } + /** + * @return DateTimeImmutable|null + */ public function getCreatedAt(): ?DateTimeImmutable { return $this->createdAt; } + /** + * @return JobDownloadUrl|null + */ public function getDownloadUrl(): ?JobDownloadUrl { return $this->downloadUrl; } + /** + * @return string|null + */ public function getId(): ?string { return $this->id; } + /** + * @return int + */ public function getQuantity(): int { return $this->quantity; } + /** + * @return int + */ public function getRecordsProcessed(): int { return $this->recordsProcessed; } + /** + * @return string|null + */ public function getStatus(): ?string { return $this->status; } + /** + * @return Summary|null + */ public function getSummary(): ?Summary { return $this->summary; From 8e8e034bdfb8393bdba6902f1f4eb7d24914dd9e Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sun, 9 Apr 2023 14:44:22 +0300 Subject: [PATCH 2/6] - Add pagination to Mailinglist members - Additional check for avoiding possible error - Some phpdoc updates --- src/Api/Attachment.php | 5 +++- src/Api/Domain.php | 27 ++++++++++----------- src/Api/EmailValidation.php | 8 +++---- src/Api/EmailValidationV4.php | 44 +++++++++++----------------------- src/Api/Event.php | 4 +++- src/Api/HttpApi.php | 15 ++++++------ src/Api/HttpClient.php | 7 +++--- src/Api/Ip.php | 11 +++++---- src/Api/Mailboxes.php | 15 ++++++------ src/Api/MailingList.php | 45 ++++++++++------------------------- src/Api/Message.php | 11 ++++++--- src/Api/Pagination.php | 26 +++++++++++++++++++- src/Api/Route.php | 32 +++++++++++-------------- src/Api/Stats.php | 2 ++ src/Api/Suppression.php | 12 ++++++++++ src/Api/Tag.php | 15 +++++++----- src/Api/Webhook.php | 26 +++++++++++++++++--- 17 files changed, 168 insertions(+), 137 deletions(-) diff --git a/src/Api/Attachment.php b/src/Api/Attachment.php index 09bc10f8..7938e152 100644 --- a/src/Api/Attachment.php +++ b/src/Api/Attachment.php @@ -12,6 +12,7 @@ namespace Mailgun\Api; use Mailgun\Assert; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; /** @@ -20,9 +21,11 @@ class Attachment extends HttpApi { /** + * @param string $url * @return ResponseInterface + * @throws ClientExceptionInterface */ - public function show(string $url) + public function show(string $url): ResponseInterface { Assert::stringNotEmpty($url); Assert::regex($url, '@https://.*mailgun\.(net|org)/v.+@'); diff --git a/src/Api/Domain.php b/src/Api/Domain.php index 34ee145a..b3b4b1ae 100644 --- a/src/Api/Domain.php +++ b/src/Api/Domain.php @@ -43,11 +43,13 @@ class Domain extends HttpApi /** * Returns a list of domains on the account. - * + * @param int $limit + * @param int $skip * @return IndexResponse * @throws ClientExceptionInterface + * @throws Exception */ - public function index(int $limit = 100, int $skip = 0) + public function index(int $limit = 100, int $skip = 0): IndexResponse { Assert::range($limit, 1, 1000); @@ -82,19 +84,16 @@ public function show(string $domain) * Creates a new domain for the account. * See below for spam filtering parameter information. * {@link https://documentation.mailgun.com/user_manual.html#um-spam-filter}. - * * @see https://documentation.mailgun.com/en/latest/api-domains.html#domains - * - * @param string $domain name of the domain - * @param string $smtpPass password for SMTP authentication - * @param string $spamAction `disable` or `tag` - inbound spam filtering - * @param bool $wildcard domain will accept email for subdomains - * @param bool $forceDkimAuthority force DKIM authority - * @param string[] $ips an array of ips to be assigned to the domain - * @param ?string $pool_id pool id to assign to the domain - * @param string $webScheme `http` or `https` - set your open, click and unsubscribe URLs to use http or https. The default is http - * @param string $dkimKeySize Set length of your domain’s generated DKIM key - * + * @param string $domain name of the domain + * @param string|null $smtpPass password for SMTP authentication + * @param string|null $spamAction `disable` or `tag` - inbound spam filtering + * @param bool $wildcard domain will accept email for subdomains + * @param bool $forceDkimAuthority force DKIM authority + * @param string[] $ips an array of ips to be assigned to the domain + * @param ?string $pool_id pool id to assign to the domain + * @param string $webScheme `http` or `https` - set your open, click and unsubscribe URLs to use http or https. The default is http + * @param string $dkimKeySize Set length of your domain’s generated DKIM key * @return CreateResponse|array|ResponseInterface * @throws Exception */ diff --git a/src/Api/EmailValidation.php b/src/Api/EmailValidation.php index 3e4064a7..2824fa21 100644 --- a/src/Api/EmailValidation.php +++ b/src/Api/EmailValidation.php @@ -17,6 +17,7 @@ use Mailgun\Exception\InvalidArgumentException; use Mailgun\Model\EmailValidation\ParseResponse; use Mailgun\Model\EmailValidation\ValidateResponse; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; /** @@ -28,18 +29,15 @@ class EmailValidation extends HttpApi { /** * Addresses are validated based off defined checks. - * * This operation is only accessible with the private API key and not subject to the daily usage limits. - * * @param string $address An email address to validate. Maximum: 512 characters. * @param bool $mailboxVerification If set to true, a mailbox verification check will be performed * against the address. The default is False. - * * @return ValidateResponse|ResponseInterface * @throws InvalidArgumentException Thrown when local validation returns an error * @throws HttpClientException Thrown when there's an error on Client side * @throws HttpServerException Thrown when there's an error on Server side - * @throws \Exception Thrown when we don't catch a Client or Server side Exception + * @throws \Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception */ public function validate(string $address, bool $mailboxVerification = false) { @@ -76,7 +74,7 @@ public function validate(string $address, bool $mailboxVerification = false) * @throws InvalidArgumentException Thrown when local validation returns an error * @throws HttpClientException Thrown when there's an error on Client side * @throws HttpServerException Thrown when there's an error on Server side - * @throws \Exception Thrown when we don't catch a Client or Server side Exception + * @throws \Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception */ public function parse(string $addresses, bool $syntaxOnly = true) { diff --git a/src/Api/EmailValidationV4.php b/src/Api/EmailValidationV4.php index 01c8d9ad..efde8a04 100755 --- a/src/Api/EmailValidationV4.php +++ b/src/Api/EmailValidationV4.php @@ -22,6 +22,7 @@ use Mailgun\Model\EmailValidationV4\GetBulkPreviewsResponse; use Mailgun\Model\EmailValidationV4\PromoteBulkPreviewResponse; use Mailgun\Model\EmailValidationV4\ValidateResponse; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; /** @@ -31,13 +32,10 @@ class EmailValidationV4 extends HttpApi { /** * Addresses are validated based off defined checks. - * * @param string $address An email address to validate. Maximum: 512 characters. * @param bool $providerLookup A provider lookup will be performed if Mailgun’s internal analysis is insufficient - * * @return ValidateResponse|ResponseInterface - * - * @throws Exception Thrown when we don't catch a Client or Server side Exception + * @throws Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception */ public function validate(string $address, bool $providerLookup = true) { @@ -56,10 +54,8 @@ public function validate(string $address, bool $providerLookup = true) /** * @param string $listId ID given when the list created * @param mixed $filePath File path or file content - * * @return mixed|ResponseInterface - * - * @throws Exception + * @throws Exception|ClientExceptionInterface */ public function createBulkJob(string $listId, $filePath) { @@ -85,10 +81,8 @@ public function createBulkJob(string $listId, $filePath) /** * @param string $listId ID given when the list created - * * @return DeleteBulkJobResponse|ResponseInterface - * - * @throws Exception + * @throws Exception|ClientExceptionInterface */ public function deleteBulkJob(string $listId) { @@ -117,10 +111,8 @@ public function getBulkJob(string $listId) /** * @param int $limit Jobs limit - * * @return GetBulkJobsResponse|ResponseInterface - * - * @throws Exception + * @throws Exception|ClientExceptionInterface */ public function getBulkJobs(int $limit = 500) { @@ -135,10 +127,8 @@ public function getBulkJobs(int $limit = 500) /** * @param int $limit Previews Limit - * * @return mixed|ResponseInterface - * - * @throws Exception + * @throws Exception|ClientExceptionInterface */ public function getBulkPreviews(int $limit = 500) { @@ -154,10 +144,8 @@ public function getBulkPreviews(int $limit = 500) /** * @param string $previewId ID given when the list created * @param mixed $filePath File path or file content - * * @return mixed|ResponseInterface - * - * @throws Exception + * @throws Exception|ClientExceptionInterface */ public function createBulkPreview(string $previewId, $filePath) { @@ -183,10 +171,8 @@ public function createBulkPreview(string $previewId, $filePath) /** * @param string $previewId ID given when the list created - * * @return mixed|ResponseInterface - * - * @throws Exception + * @throws Exception|ClientExceptionInterface */ public function getBulkPreview(string $previewId) { @@ -199,10 +185,10 @@ public function getBulkPreview(string $previewId) /** * @param string $previewId ID given when the list created - * * @return bool + * @throws ClientExceptionInterface */ - public function deleteBulkPreview(string $previewId) + public function deleteBulkPreview(string $previewId): bool { Assert::stringNotEmpty($previewId); @@ -213,10 +199,8 @@ public function deleteBulkPreview(string $previewId) /** * @param string $previewId ID given when the list created - * * @return mixed|ResponseInterface - * - * @throws Exception + * @throws Exception|ClientExceptionInterface */ public function promoteBulkPreview(string $previewId) { @@ -235,19 +219,19 @@ public function promoteBulkPreview(string $previewId) */ private function prepareFile(string $fieldName, array $filePath): array { - $filename = isset($filePath['filename']) ? $filePath['filename'] : null; + $filename = $filePath['filename'] ?? null; $resource = null; if (isset($filePath['fileContent'])) { // File from memory - $resource = fopen('php://temp', 'r+'); + $resource = fopen('php://temp', 'rb+'); fwrite($resource, $filePath['fileContent']); rewind($resource); } elseif (isset($filePath['filePath'])) { // File form path $path = $filePath['filePath']; - $resource = fopen($path, 'r'); + $resource = fopen($path, 'rb'); } return [ diff --git a/src/Api/Event.php b/src/Api/Event.php index 748f1bdd..69248ebb 100644 --- a/src/Api/Event.php +++ b/src/Api/Event.php @@ -13,6 +13,7 @@ use Mailgun\Assert; use Mailgun\Model\Event\EventResponse; +use Psr\Http\Client\ClientExceptionInterface; /** * @see https://documentation.mailgun.com/en/latest/api-events.html @@ -25,8 +26,9 @@ class Event extends HttpApi /** * @return EventResponse + * @throws ClientExceptionInterface */ - public function get(string $domain, array $params = []) + public function get(string $domain, array $params = []): EventResponse { Assert::stringNotEmpty($domain); diff --git a/src/Api/HttpApi.php b/src/Api/HttpApi.php index 44233d06..48f7a9a0 100644 --- a/src/Api/HttpApi.php +++ b/src/Api/HttpApi.php @@ -11,6 +11,7 @@ namespace Mailgun\Api; +use Exception; use Mailgun\Exception\HttpClientException; use Mailgun\Exception\HttpServerException; use Mailgun\Exception\UnknownErrorException; @@ -63,7 +64,7 @@ public function __construct($httpClient, RequestBuilder $requestBuilder, Hydrato * * @return mixed|ResponseInterface * - * @throws \Exception + * @throws Exception */ protected function hydrateResponse(ResponseInterface $response, string $class) { @@ -81,9 +82,9 @@ protected function hydrateResponse(ResponseInterface $response, string $class) /** * Throw the correct exception for this error. * - * @throws \Exception + * @throws Exception|UnknownErrorException */ - protected function handleErrors(ResponseInterface $response) + protected function handleErrors(ResponseInterface $response): void { $statusCode = $response->getStatusCode(); switch ($statusCode) { @@ -137,10 +138,10 @@ protected function httpGet(string $path, array $parameters = [], array $requestH /** * Send a POST request with parameters. - * - * @param string $path Request path - * @param array $parameters POST parameters - * @param array $requestHeaders Request headers + * @param string $path Request path + * @param array $parameters POST parameters + * @param array $requestHeaders Request headers + * @throws ClientExceptionInterface */ protected function httpPost(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface { diff --git a/src/Api/HttpClient.php b/src/Api/HttpClient.php index ecfe282d..de386717 100644 --- a/src/Api/HttpClient.php +++ b/src/Api/HttpClient.php @@ -65,10 +65,11 @@ public function httpGet(string $path, array $parameters = [], array $requestHead } /** - * @param string $path - * @param array $parameters - * @param array $requestHeaders + * @param string $path + * @param array $parameters + * @param array $requestHeaders * @return ResponseInterface + * @throws ClientExceptionInterface */ public function httpPost(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface { diff --git a/src/Api/Ip.php b/src/Api/Ip.php index 35294d18..131ee8eb 100644 --- a/src/Api/Ip.php +++ b/src/Api/Ip.php @@ -15,6 +15,7 @@ use Mailgun\Model\Ip\IndexResponse; use Mailgun\Model\Ip\ShowResponse; use Mailgun\Model\Ip\UpdateResponse; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; /** @@ -26,8 +27,8 @@ class Ip extends HttpApi { /** * Returns a list of IPs. - * * @return IndexResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function index(?bool $dedicated = null) { @@ -44,8 +45,8 @@ public function index(?bool $dedicated = null) /** * Returns a list of IPs assigned to a domain. - * * @return IndexResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function domainIndex(string $domain) { @@ -58,8 +59,8 @@ public function domainIndex(string $domain) /** * Returns a single ip. - * * @return ShowResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function show(string $ip) { @@ -72,8 +73,8 @@ public function show(string $ip) /** * Assign a dedicated IP to the domain specified. - * * @return UpdateResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function assign(string $domain, string $ip) { @@ -91,8 +92,8 @@ public function assign(string $domain, string $ip) /** * Unassign an IP from the domain specified. - * * @return UpdateResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function unassign(string $domain, string $ip) { diff --git a/src/Api/Mailboxes.php b/src/Api/Mailboxes.php index cea67844..0c5bb6a4 100644 --- a/src/Api/Mailboxes.php +++ b/src/Api/Mailboxes.php @@ -16,15 +16,17 @@ use Mailgun\Model\Mailboxes\DeleteResponse; use Mailgun\Model\Mailboxes\ShowResponse; use Mailgun\Model\Mailboxes\UpdateResponse; +use Psr\Http\Client\ClientExceptionInterface; class Mailboxes extends HttpApi { private const MIN_PASSWORD_LENGTH = 5; /** + * @param string $domain + * @param array $parameters * @return CreateResponse - * - * @throws \Exception + * @throws ClientExceptionInterface */ public function create(string $domain, array $parameters = []) { @@ -40,8 +42,7 @@ public function create(string $domain, array $parameters = []) /** * @return ShowResponse - * - * @throws \Exception + * @throws \Exception|ClientExceptionInterface */ public function show(string $domain, array $parameters = []) { @@ -54,8 +55,7 @@ public function show(string $domain, array $parameters = []) /** * @return UpdateResponse - * - * @throws \Exception + * @throws \Exception|ClientExceptionInterface */ public function update(string $domain, string $mailbox, array $parameters = []) { @@ -69,8 +69,7 @@ public function update(string $domain, string $mailbox, array $parameters = []) /** * @return DeleteResponse - * - * @throws \Exception + * @throws \Exception|ClientExceptionInterface */ public function delete(string $domain, string $mailbox) { diff --git a/src/Api/MailingList.php b/src/Api/MailingList.php index c35c053d..c825ad5c 100644 --- a/src/Api/MailingList.php +++ b/src/Api/MailingList.php @@ -11,6 +11,7 @@ namespace Mailgun\Api; +use Exception; use Mailgun\Api\MailingList\Member; use Mailgun\Assert; use Mailgun\Model\EmailValidation\ValidateResponse; @@ -21,12 +22,16 @@ use Mailgun\Model\MailingList\UpdateResponse; use Mailgun\Model\MailingList\ValidationCancelResponse; use Mailgun\Model\MailingList\ValidationStatusResponse; +use Psr\Http\Client\ClientExceptionInterface; /** * @see https://documentation.mailgun.com/en/latest/api-mailinglists.html */ class MailingList extends HttpApi { + /** + * @return Member + */ public function member(): Member { return new Member($this->httpClient, $this->requestBuilder, $this->hydrator); @@ -34,12 +39,9 @@ public function member(): Member /** * Returns a paginated list of mailing lists on the domain. - * * @param int $limit Maximum number of records to return (optional: 100 by default) - * * @return PagesResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function pages(int $limit = 100) { @@ -56,16 +58,13 @@ public function pages(int $limit = 100) /** * Creates a new mailing list on the current domain. - * * @param string $address Address for the new mailing list * @param string|null $name Name for the new mailing list (optional) * @param string|null $description Description for the new mailing list (optional) * @param string $accessLevel List access level, one of: readonly (default), members, everyone * @param string $replyPreference Set where replies should go: list (default) | sender (optional) - * * @return CreateResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function create(string $address, ?string $name = null, ?string $description = null, string $accessLevel = 'readonly', string $replyPreference = 'list') { @@ -90,12 +89,9 @@ public function create(string $address, ?string $name = null, ?string $descripti /** * Returns a single mailing list. - * * @param string $address Address of the mailing list - * * @return ShowResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function show(string $address) { @@ -108,13 +104,10 @@ public function show(string $address) /** * Updates a mailing list. - * * @param string $address Address of the mailing list * @param array $parameters Array of field => value pairs to update - * * @return UpdateResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function update(string $address, array $parameters = []) { @@ -143,12 +136,9 @@ public function update(string $address, array $parameters = []) /** * Removes a mailing list from the domain. - * * @param string $address Address of the mailing list - * * @return DeleteResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function delete(string $address) { @@ -161,12 +151,9 @@ public function delete(string $address) /** * Validates mailing list. - * * @param string $address Address of the mailing list - * * @return ValidateResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function validate(string $address) { @@ -179,12 +166,9 @@ public function validate(string $address) /** * Get mailing list validation status. - * * @param string $address Address of the mailing list - * * @return ValidationStatusResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function getValidationStatus(string $address) { @@ -197,12 +181,9 @@ public function getValidationStatus(string $address) /** * Cancel mailing list validation. - * * @param string $address Address of the mailing list - * * @return ValidationCancelResponse - * - * @throws \Exception + * @throws Exception|ClientExceptionInterface */ public function cancelValidation(string $address) { diff --git a/src/Api/Message.php b/src/Api/Message.php index 558e3e90..80e7ebc0 100644 --- a/src/Api/Message.php +++ b/src/Api/Message.php @@ -27,6 +27,11 @@ */ class Message extends HttpApi { + /** + * @param string $domain + * @param bool $autoSend + * @return BatchMessage + */ public function getBatchMessage(string $domain, bool $autoSend = true): BatchMessage { return new BatchMessage($this, $domain, $autoSend); @@ -134,11 +139,11 @@ public function show(string $url, bool $rawMessage = false) */ private function prepareFile(string $fieldName, array $filePath): array { - $filename = isset($filePath['filename']) ? $filePath['filename'] : null; + $filename = $filePath['filename'] ?? null; if (isset($filePath['fileContent'])) { // File from memory - $resource = fopen('php://temp', 'r+'); + $resource = fopen('php://temp', 'rb+'); fwrite($resource, $filePath['fileContent']); rewind($resource); } elseif (isset($filePath['filePath'])) { @@ -150,7 +155,7 @@ private function prepareFile(string $fieldName, array $filePath): array $path = substr($path, 1); } - $resource = fopen($path, 'r'); + $resource = fopen($path, 'rb'); } else { throw new InvalidArgumentException('When using a file you need to specify parameter "fileContent" or "filePath"'); } diff --git a/src/Api/Pagination.php b/src/Api/Pagination.php index 1ec3e0f5..faa0e0cd 100644 --- a/src/Api/Pagination.php +++ b/src/Api/Pagination.php @@ -13,6 +13,7 @@ use Mailgun\Assert; use Mailgun\Model\PagingProvider; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; /** @@ -27,28 +28,51 @@ abstract protected function httpGet(string $path, array $parameters = [], array */ abstract protected function hydrateResponse(ResponseInterface $response, string $className); + /** + * @param PagingProvider $response + * @return PagingProvider|null + * @throws ClientExceptionInterface + */ public function nextPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getNextUrl(), get_class($response)); } + /** + * @param PagingProvider $response + * @return PagingProvider|null + * @throws ClientExceptionInterface + */ public function previousPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getPreviousUrl(), get_class($response)); } + /** + * @param PagingProvider $response + * @return PagingProvider|null + */ public function firstPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getFirstUrl(), get_class($response)); } + /** + * @param PagingProvider $response + * @return PagingProvider|null + * @throws ClientExceptionInterface + */ public function lastPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getLastUrl(), get_class($response)); } + /** - * @param class-string $class + * @param string $url + * @param string $class + * @return PagingProvider|null + * @throws ClientExceptionInterface */ private function getPaginationUrl(string $url, string $class): ?PagingProvider { diff --git a/src/Api/Route.php b/src/Api/Route.php index 8081a2c0..67852cf2 100644 --- a/src/Api/Route.php +++ b/src/Api/Route.php @@ -17,6 +17,7 @@ use Mailgun\Model\Route\IndexResponse; use Mailgun\Model\Route\ShowResponse; use Mailgun\Model\Route\UpdateResponse; +use Psr\Http\Client\ClientExceptionInterface; /** * @see https://documentation.mailgun.com/api-routes.html @@ -27,11 +28,10 @@ class Route extends HttpApi { /** * Fetches the list of Routes. - * * @param int $limit Maximum number of records to return. (100 by default) - * @param int $skip Number of records to skip. (0 by default) - * + * @param int $skip Number of records to skip. (0 by default) * @return IndexResponse + * @throws ClientExceptionInterface */ public function index(int $limit = 100, int $skip = 0) { @@ -51,10 +51,9 @@ public function index(int $limit = 100, int $skip = 0) /** * Returns a single Route object based on its ID. - * * @param string $routeId Route ID returned by the Routes::index() method - * * @return ShowResponse + * @throws ClientExceptionInterface */ public function show(string $routeId) { @@ -67,13 +66,12 @@ public function show(string $routeId) /** * Creates a new Route. - * - * @param string $expression A filter expression like "match_recipient('.*@gmail.com')" - * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" + * @param string $expression A filter expression like "match_recipient('.*@gmail.com')" + * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" * @param string $description An arbitrary string - * @param int $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. - * + * @param int $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. * @return CreateResponse + * @throws ClientExceptionInterface */ public function create(string $expression, array $actions, string $description, int $priority = 0) { @@ -94,14 +92,13 @@ public function create(string $expression, array $actions, string $description, /** * Updates a given Route by ID. All parameters are optional. * This API call only updates the specified fields leaving others unchanged. - * - * @param string $routeId Route ID returned by the Routes::index() method - * @param string|null $expression A filter expression like "match_recipient('.*@gmail.com')" - * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" + * @param string $routeId Route ID returned by the Routes::index() method + * @param string|null $expression A filter expression like "match_recipient('.*@gmail.com')" + * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" * @param string|null $description An arbitrary string - * @param int|null $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. - * + * @param int|null $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. * @return UpdateResponse + * @throws ClientExceptionInterface */ public function update( string $routeId, @@ -139,10 +136,9 @@ public function update( /** * Deletes a Route based on the ID. - * * @param string $routeId Route ID returned by the Routes::index() method - * * @return DeleteResponse + * @throws ClientExceptionInterface */ public function delete(string $routeId) { diff --git a/src/Api/Stats.php b/src/Api/Stats.php index 1d894cbd..b7c3ed4f 100644 --- a/src/Api/Stats.php +++ b/src/Api/Stats.php @@ -13,6 +13,7 @@ use Mailgun\Assert; use Mailgun\Model\Stats\TotalResponse; +use Psr\Http\Client\ClientExceptionInterface; /** * @see https://documentation.mailgun.com/en/latest/api-stats.html @@ -23,6 +24,7 @@ class Stats extends HttpApi { /** * @return TotalResponse|array + * @throws ClientExceptionInterface */ public function total(string $domain, array $params = []) { diff --git a/src/Api/Suppression.php b/src/Api/Suppression.php index 968ce66f..f3faf1ee 100644 --- a/src/Api/Suppression.php +++ b/src/Api/Suppression.php @@ -53,21 +53,33 @@ public function __construct($httpClient, RequestBuilder $requestBuilder, Hydrato $this->hydrator = $hydrator; } + /** + * @return Bounce + */ public function bounces(): Bounce { return new Bounce($this->httpClient, $this->requestBuilder, $this->hydrator); } + /** + * @return Complaint + */ public function complaints(): Complaint { return new Complaint($this->httpClient, $this->requestBuilder, $this->hydrator); } + /** + * @return Unsubscribe + */ public function unsubscribes(): Unsubscribe { return new Unsubscribe($this->httpClient, $this->requestBuilder, $this->hydrator); } + /** + * @return Whitelist + */ public function whitelists(): Whitelist { return new Whitelist($this->httpClient, $this->requestBuilder, $this->hydrator); diff --git a/src/Api/Tag.php b/src/Api/Tag.php index 9f1c448a..b6c6717a 100644 --- a/src/Api/Tag.php +++ b/src/Api/Tag.php @@ -20,6 +20,7 @@ use Mailgun\Model\Tag\ShowResponse; use Mailgun\Model\Tag\StatisticsResponse; use Mailgun\Model\Tag\UpdateResponse; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\ResponseInterface; /** @@ -33,9 +34,8 @@ class Tag extends HttpApi /** * Returns a list of tags. - - * * @return IndexResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function index(string $domain, int $limit = 100) { @@ -53,8 +53,8 @@ public function index(string $domain, int $limit = 100) /** * Returns a single tag. - * * @return ShowResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function show(string $domain, string $tag) { @@ -68,8 +68,8 @@ public function show(string $domain, string $tag) /** * Update a tag. - * * @return UpdateResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function update(string $domain, string $tag, string $description) { @@ -87,8 +87,8 @@ public function update(string $domain, string $tag, string $description) /** * Returns statistics for a single tag. - * * @return StatisticsResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function stats(string $domain, string $tag, array $params) { @@ -102,8 +102,8 @@ public function stats(string $domain, string $tag, array $params) /** * Removes a tag from the account. - * * @return DeleteResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function delete(string $domain, string $tag) { @@ -117,6 +117,7 @@ public function delete(string $domain, string $tag) /** * @return CountryResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function countries(string $domain, string $tag) { @@ -130,6 +131,7 @@ public function countries(string $domain, string $tag) /** * @return ProviderResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function providers(string $domain, string $tag) { @@ -143,6 +145,7 @@ public function providers(string $domain, string $tag) /** * @return DeviceResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function devices(string $domain, string $tag) { diff --git a/src/Api/Webhook.php b/src/Api/Webhook.php index 7d52af89..750ed3e2 100644 --- a/src/Api/Webhook.php +++ b/src/Api/Webhook.php @@ -19,6 +19,7 @@ use Mailgun\Model\Webhook\IndexResponse; use Mailgun\Model\Webhook\ShowResponse; use Mailgun\Model\Webhook\UpdateResponse; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\ResponseInterface; @@ -48,9 +49,12 @@ public function __construct($httpClient, RequestBuilder $requestBuilder, Hydrato /** * This function verifies the webhook signature with your API key to to see if it is authentic. - * * If this function returns FALSE, you must not process the request. * You should reject the request with status code 403 Forbidden. + * @param int $timestamp + * @param string $token + * @param string $signature + * @return bool */ public function verifyWebhookSignature(int $timestamp, string $token, string $signature): bool { @@ -63,13 +67,15 @@ public function verifyWebhookSignature(int $timestamp, string $token, string $si if (function_exists('hash_equals')) { // hash_equals is constant time, but will not be introduced until PHP 5.6 return hash_equals($hmac, $signature); - } else { - return $hmac === $signature; } + + return $hmac === $signature; } /** + * @param string $domain * @return IndexResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function index(string $domain) { @@ -80,7 +86,10 @@ public function index(string $domain) } /** + * @param string $domain + * @param string $webhook * @return ShowResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function show(string $domain, string $webhook) { @@ -92,7 +101,11 @@ public function show(string $domain, string $webhook) } /** + * @param string $domain + * @param string $id + * @param array $url * @return CreateResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function create(string $domain, string $id, array $url) { @@ -111,7 +124,11 @@ public function create(string $domain, string $id, array $url) } /** + * @param string $domain + * @param string $id + * @param array $url * @return UpdateResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function update(string $domain, string $id, array $url) { @@ -129,7 +146,10 @@ public function update(string $domain, string $id, array $url) } /** + * @param string $domain + * @param string $id * @return DeleteResponse|ResponseInterface + * @throws ClientExceptionInterface */ public function delete(string $domain, string $id) { From d6bcf0407b1096321eefb2e81de03ce57af68aa6 Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sun, 9 Apr 2023 14:45:56 +0300 Subject: [PATCH 3/6] Fix code style --- src/Api/Attachment.php | 2 +- src/Api/Domain.php | 22 +++++++++++----------- src/Api/EmailValidation.php | 22 +++++++++++----------- src/Api/EmailValidationV4.php | 24 ++++++++++++------------ src/Api/HttpApi.php | 6 +++--- src/Api/HttpClient.php | 6 +++--- src/Api/Mailboxes.php | 4 ++-- src/Api/MailingList.php | 26 +++++++++++++------------- src/Api/MailingList/Member.php | 13 ++++++------- src/Api/Message.php | 4 ++-- src/Api/Pagination.php | 13 ++++++------- src/Api/Route.php | 26 +++++++++++++------------- src/Api/Webhook.php | 28 ++++++++++++++-------------- src/Model/EmailValidationV4/Job.php | 2 +- 14 files changed, 98 insertions(+), 100 deletions(-) diff --git a/src/Api/Attachment.php b/src/Api/Attachment.php index 7938e152..49e7c6ab 100644 --- a/src/Api/Attachment.php +++ b/src/Api/Attachment.php @@ -21,7 +21,7 @@ class Attachment extends HttpApi { /** - * @param string $url + * @param string $url * @return ResponseInterface * @throws ClientExceptionInterface */ diff --git a/src/Api/Domain.php b/src/Api/Domain.php index b3b4b1ae..d9c36dd8 100644 --- a/src/Api/Domain.php +++ b/src/Api/Domain.php @@ -43,8 +43,8 @@ class Domain extends HttpApi /** * Returns a list of domains on the account. - * @param int $limit - * @param int $skip + * @param int $limit + * @param int $skip * @return IndexResponse * @throws ClientExceptionInterface * @throws Exception @@ -85,15 +85,15 @@ public function show(string $domain) * See below for spam filtering parameter information. * {@link https://documentation.mailgun.com/user_manual.html#um-spam-filter}. * @see https://documentation.mailgun.com/en/latest/api-domains.html#domains - * @param string $domain name of the domain - * @param string|null $smtpPass password for SMTP authentication - * @param string|null $spamAction `disable` or `tag` - inbound spam filtering - * @param bool $wildcard domain will accept email for subdomains - * @param bool $forceDkimAuthority force DKIM authority - * @param string[] $ips an array of ips to be assigned to the domain - * @param ?string $pool_id pool id to assign to the domain - * @param string $webScheme `http` or `https` - set your open, click and unsubscribe URLs to use http or https. The default is http - * @param string $dkimKeySize Set length of your domain’s generated DKIM key + * @param string $domain name of the domain + * @param string|null $smtpPass password for SMTP authentication + * @param string|null $spamAction `disable` or `tag` - inbound spam filtering + * @param bool $wildcard domain will accept email for subdomains + * @param bool $forceDkimAuthority force DKIM authority + * @param string[] $ips an array of ips to be assigned to the domain + * @param ?string $pool_id pool id to assign to the domain + * @param string $webScheme `http` or `https` - set your open, click and unsubscribe URLs to use http or https. The default is http + * @param string $dkimKeySize Set length of your domain’s generated DKIM key * @return CreateResponse|array|ResponseInterface * @throws Exception */ diff --git a/src/Api/EmailValidation.php b/src/Api/EmailValidation.php index 2824fa21..e8b5031c 100644 --- a/src/Api/EmailValidation.php +++ b/src/Api/EmailValidation.php @@ -30,14 +30,14 @@ class EmailValidation extends HttpApi /** * Addresses are validated based off defined checks. * This operation is only accessible with the private API key and not subject to the daily usage limits. - * @param string $address An email address to validate. Maximum: 512 characters. - * @param bool $mailboxVerification If set to true, a mailbox verification check will be performed - * against the address. The default is False. + * @param string $address An email address to validate. Maximum: 512 characters. + * @param bool $mailboxVerification If set to true, a mailbox verification check will be performed + * against the address. The default is False. * @return ValidateResponse|ResponseInterface - * @throws InvalidArgumentException Thrown when local validation returns an error - * @throws HttpClientException Thrown when there's an error on Client side - * @throws HttpServerException Thrown when there's an error on Server side - * @throws \Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception + * @throws InvalidArgumentException Thrown when local validation returns an error + * @throws HttpClientException Thrown when there's an error on Client side + * @throws HttpServerException Thrown when there's an error on Server side + * @throws \Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception */ public function validate(string $address, bool $mailboxVerification = false) { @@ -71,10 +71,10 @@ public function validate(string $address, bool $mailboxVerification = false) * The default is True. * * @return ParseResponse|ResponseInterface - * @throws InvalidArgumentException Thrown when local validation returns an error - * @throws HttpClientException Thrown when there's an error on Client side - * @throws HttpServerException Thrown when there's an error on Server side - * @throws \Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception + * @throws InvalidArgumentException Thrown when local validation returns an error + * @throws HttpClientException Thrown when there's an error on Client side + * @throws HttpServerException Thrown when there's an error on Server side + * @throws \Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception */ public function parse(string $addresses, bool $syntaxOnly = true) { diff --git a/src/Api/EmailValidationV4.php b/src/Api/EmailValidationV4.php index efde8a04..cdf276ff 100755 --- a/src/Api/EmailValidationV4.php +++ b/src/Api/EmailValidationV4.php @@ -32,8 +32,8 @@ class EmailValidationV4 extends HttpApi { /** * Addresses are validated based off defined checks. - * @param string $address An email address to validate. Maximum: 512 characters. - * @param bool $providerLookup A provider lookup will be performed if Mailgun’s internal analysis is insufficient + * @param string $address An email address to validate. Maximum: 512 characters. + * @param bool $providerLookup A provider lookup will be performed if Mailgun’s internal analysis is insufficient * @return ValidateResponse|ResponseInterface * @throws Exception|ClientExceptionInterface Thrown when we don't catch a Client or Server side Exception */ @@ -52,8 +52,8 @@ public function validate(string $address, bool $providerLookup = true) } /** - * @param string $listId ID given when the list created - * @param mixed $filePath File path or file content + * @param string $listId ID given when the list created + * @param mixed $filePath File path or file content * @return mixed|ResponseInterface * @throws Exception|ClientExceptionInterface */ @@ -80,7 +80,7 @@ public function createBulkJob(string $listId, $filePath) } /** - * @param string $listId ID given when the list created + * @param string $listId ID given when the list created * @return DeleteBulkJobResponse|ResponseInterface * @throws Exception|ClientExceptionInterface */ @@ -110,7 +110,7 @@ public function getBulkJob(string $listId) } /** - * @param int $limit Jobs limit + * @param int $limit Jobs limit * @return GetBulkJobsResponse|ResponseInterface * @throws Exception|ClientExceptionInterface */ @@ -126,7 +126,7 @@ public function getBulkJobs(int $limit = 500) } /** - * @param int $limit Previews Limit + * @param int $limit Previews Limit * @return mixed|ResponseInterface * @throws Exception|ClientExceptionInterface */ @@ -142,8 +142,8 @@ public function getBulkPreviews(int $limit = 500) } /** - * @param string $previewId ID given when the list created - * @param mixed $filePath File path or file content + * @param string $previewId ID given when the list created + * @param mixed $filePath File path or file content * @return mixed|ResponseInterface * @throws Exception|ClientExceptionInterface */ @@ -170,7 +170,7 @@ public function createBulkPreview(string $previewId, $filePath) } /** - * @param string $previewId ID given when the list created + * @param string $previewId ID given when the list created * @return mixed|ResponseInterface * @throws Exception|ClientExceptionInterface */ @@ -184,7 +184,7 @@ public function getBulkPreview(string $previewId) } /** - * @param string $previewId ID given when the list created + * @param string $previewId ID given when the list created * @return bool * @throws ClientExceptionInterface */ @@ -198,7 +198,7 @@ public function deleteBulkPreview(string $previewId): bool } /** - * @param string $previewId ID given when the list created + * @param string $previewId ID given when the list created * @return mixed|ResponseInterface * @throws Exception|ClientExceptionInterface */ diff --git a/src/Api/HttpApi.php b/src/Api/HttpApi.php index 48f7a9a0..f34e570c 100644 --- a/src/Api/HttpApi.php +++ b/src/Api/HttpApi.php @@ -138,9 +138,9 @@ protected function httpGet(string $path, array $parameters = [], array $requestH /** * Send a POST request with parameters. - * @param string $path Request path - * @param array $parameters POST parameters - * @param array $requestHeaders Request headers + * @param string $path Request path + * @param array $parameters POST parameters + * @param array $requestHeaders Request headers * @throws ClientExceptionInterface */ protected function httpPost(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface diff --git a/src/Api/HttpClient.php b/src/Api/HttpClient.php index de386717..d72fbdc6 100644 --- a/src/Api/HttpClient.php +++ b/src/Api/HttpClient.php @@ -65,9 +65,9 @@ public function httpGet(string $path, array $parameters = [], array $requestHead } /** - * @param string $path - * @param array $parameters - * @param array $requestHeaders + * @param string $path + * @param array $parameters + * @param array $requestHeaders * @return ResponseInterface * @throws ClientExceptionInterface */ diff --git a/src/Api/Mailboxes.php b/src/Api/Mailboxes.php index 0c5bb6a4..fb6be90f 100644 --- a/src/Api/Mailboxes.php +++ b/src/Api/Mailboxes.php @@ -23,8 +23,8 @@ class Mailboxes extends HttpApi private const MIN_PASSWORD_LENGTH = 5; /** - * @param string $domain - * @param array $parameters + * @param string $domain + * @param array $parameters * @return CreateResponse * @throws ClientExceptionInterface */ diff --git a/src/Api/MailingList.php b/src/Api/MailingList.php index c825ad5c..d4478bb3 100644 --- a/src/Api/MailingList.php +++ b/src/Api/MailingList.php @@ -39,7 +39,7 @@ public function member(): Member /** * Returns a paginated list of mailing lists on the domain. - * @param int $limit Maximum number of records to return (optional: 100 by default) + * @param int $limit Maximum number of records to return (optional: 100 by default) * @return PagesResponse * @throws Exception|ClientExceptionInterface */ @@ -58,11 +58,11 @@ public function pages(int $limit = 100) /** * Creates a new mailing list on the current domain. - * @param string $address Address for the new mailing list - * @param string|null $name Name for the new mailing list (optional) - * @param string|null $description Description for the new mailing list (optional) - * @param string $accessLevel List access level, one of: readonly (default), members, everyone - * @param string $replyPreference Set where replies should go: list (default) | sender (optional) + * @param string $address Address for the new mailing list + * @param string|null $name Name for the new mailing list (optional) + * @param string|null $description Description for the new mailing list (optional) + * @param string $accessLevel List access level, one of: readonly (default), members, everyone + * @param string $replyPreference Set where replies should go: list (default) | sender (optional) * @return CreateResponse * @throws Exception|ClientExceptionInterface */ @@ -89,7 +89,7 @@ public function create(string $address, ?string $name = null, ?string $descripti /** * Returns a single mailing list. - * @param string $address Address of the mailing list + * @param string $address Address of the mailing list * @return ShowResponse * @throws Exception|ClientExceptionInterface */ @@ -104,8 +104,8 @@ public function show(string $address) /** * Updates a mailing list. - * @param string $address Address of the mailing list - * @param array $parameters Array of field => value pairs to update + * @param string $address Address of the mailing list + * @param array $parameters Array of field => value pairs to update * @return UpdateResponse * @throws Exception|ClientExceptionInterface */ @@ -136,7 +136,7 @@ public function update(string $address, array $parameters = []) /** * Removes a mailing list from the domain. - * @param string $address Address of the mailing list + * @param string $address Address of the mailing list * @return DeleteResponse * @throws Exception|ClientExceptionInterface */ @@ -151,7 +151,7 @@ public function delete(string $address) /** * Validates mailing list. - * @param string $address Address of the mailing list + * @param string $address Address of the mailing list * @return ValidateResponse * @throws Exception|ClientExceptionInterface */ @@ -166,7 +166,7 @@ public function validate(string $address) /** * Get mailing list validation status. - * @param string $address Address of the mailing list + * @param string $address Address of the mailing list * @return ValidationStatusResponse * @throws Exception|ClientExceptionInterface */ @@ -181,7 +181,7 @@ public function getValidationStatus(string $address) /** * Cancel mailing list validation. - * @param string $address Address of the mailing list + * @param string $address Address of the mailing list * @return ValidationCancelResponse * @throws Exception|ClientExceptionInterface */ diff --git a/src/Api/MailingList/Member.php b/src/Api/MailingList/Member.php index abe1fcec..9f7da02f 100644 --- a/src/Api/MailingList/Member.php +++ b/src/Api/MailingList/Member.php @@ -27,7 +27,6 @@ */ class Member extends HttpApi { - use Pagination; /** @@ -83,12 +82,12 @@ public function show(string $list, string $address) /** * Creates (or updates) a member of the mailing list. - * @param string $list Address of the mailing list - * @param string $address Address for the member - * @param string|null $name Name for the member (optional) - * @param array $vars Array of field => value pairs to store additional data - * @param bool $subscribed `true` to add as subscribed (default), `false` as unsubscribed - * @param bool $upsert `true` to update member if present, `false` to raise error in case of a duplicate member (default) + * @param string $list Address of the mailing list + * @param string $address Address for the member + * @param string|null $name Name for the member (optional) + * @param array $vars Array of field => value pairs to store additional data + * @param bool $subscribed `true` to add as subscribed (default), `false` as unsubscribed + * @param bool $upsert `true` to update member if present, `false` to raise error in case of a duplicate member (default) * @return CreateResponse */ public function create(string $list, string $address, string $name = null, array $vars = [], bool $subscribed = true, bool $upsert = false) diff --git a/src/Api/Message.php b/src/Api/Message.php index 80e7ebc0..fc287f9c 100644 --- a/src/Api/Message.php +++ b/src/Api/Message.php @@ -28,8 +28,8 @@ class Message extends HttpApi { /** - * @param string $domain - * @param bool $autoSend + * @param string $domain + * @param bool $autoSend * @return BatchMessage */ public function getBatchMessage(string $domain, bool $autoSend = true): BatchMessage diff --git a/src/Api/Pagination.php b/src/Api/Pagination.php index faa0e0cd..f3b262b0 100644 --- a/src/Api/Pagination.php +++ b/src/Api/Pagination.php @@ -29,7 +29,7 @@ abstract protected function httpGet(string $path, array $parameters = [], array abstract protected function hydrateResponse(ResponseInterface $response, string $className); /** - * @param PagingProvider $response + * @param PagingProvider $response * @return PagingProvider|null * @throws ClientExceptionInterface */ @@ -39,7 +39,7 @@ public function nextPage(PagingProvider $response): ?PagingProvider } /** - * @param PagingProvider $response + * @param PagingProvider $response * @return PagingProvider|null * @throws ClientExceptionInterface */ @@ -49,7 +49,7 @@ public function previousPage(PagingProvider $response): ?PagingProvider } /** - * @param PagingProvider $response + * @param PagingProvider $response * @return PagingProvider|null */ public function firstPage(PagingProvider $response): ?PagingProvider @@ -58,7 +58,7 @@ public function firstPage(PagingProvider $response): ?PagingProvider } /** - * @param PagingProvider $response + * @param PagingProvider $response * @return PagingProvider|null * @throws ClientExceptionInterface */ @@ -67,10 +67,9 @@ public function lastPage(PagingProvider $response): ?PagingProvider return $this->getPaginationUrl($response->getLastUrl(), get_class($response)); } - /** - * @param string $url - * @param string $class + * @param string $url + * @param string $class * @return PagingProvider|null * @throws ClientExceptionInterface */ diff --git a/src/Api/Route.php b/src/Api/Route.php index 67852cf2..1534783b 100644 --- a/src/Api/Route.php +++ b/src/Api/Route.php @@ -28,8 +28,8 @@ class Route extends HttpApi { /** * Fetches the list of Routes. - * @param int $limit Maximum number of records to return. (100 by default) - * @param int $skip Number of records to skip. (0 by default) + * @param int $limit Maximum number of records to return. (100 by default) + * @param int $skip Number of records to skip. (0 by default) * @return IndexResponse * @throws ClientExceptionInterface */ @@ -51,7 +51,7 @@ public function index(int $limit = 100, int $skip = 0) /** * Returns a single Route object based on its ID. - * @param string $routeId Route ID returned by the Routes::index() method + * @param string $routeId Route ID returned by the Routes::index() method * @return ShowResponse * @throws ClientExceptionInterface */ @@ -66,10 +66,10 @@ public function show(string $routeId) /** * Creates a new Route. - * @param string $expression A filter expression like "match_recipient('.*@gmail.com')" - * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" - * @param string $description An arbitrary string - * @param int $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. + * @param string $expression A filter expression like "match_recipient('.*@gmail.com')" + * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" + * @param string $description An arbitrary string + * @param int $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. * @return CreateResponse * @throws ClientExceptionInterface */ @@ -92,11 +92,11 @@ public function create(string $expression, array $actions, string $description, /** * Updates a given Route by ID. All parameters are optional. * This API call only updates the specified fields leaving others unchanged. - * @param string $routeId Route ID returned by the Routes::index() method - * @param string|null $expression A filter expression like "match_recipient('.*@gmail.com')" - * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" - * @param string|null $description An arbitrary string - * @param int|null $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. + * @param string $routeId Route ID returned by the Routes::index() method + * @param string|null $expression A filter expression like "match_recipient('.*@gmail.com')" + * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" + * @param string|null $description An arbitrary string + * @param int|null $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. * @return UpdateResponse * @throws ClientExceptionInterface */ @@ -136,7 +136,7 @@ public function update( /** * Deletes a Route based on the ID. - * @param string $routeId Route ID returned by the Routes::index() method + * @param string $routeId Route ID returned by the Routes::index() method * @return DeleteResponse * @throws ClientExceptionInterface */ diff --git a/src/Api/Webhook.php b/src/Api/Webhook.php index 750ed3e2..7f670f7a 100644 --- a/src/Api/Webhook.php +++ b/src/Api/Webhook.php @@ -51,9 +51,9 @@ public function __construct($httpClient, RequestBuilder $requestBuilder, Hydrato * This function verifies the webhook signature with your API key to to see if it is authentic. * If this function returns FALSE, you must not process the request. * You should reject the request with status code 403 Forbidden. - * @param int $timestamp - * @param string $token - * @param string $signature + * @param int $timestamp + * @param string $token + * @param string $signature * @return bool */ public function verifyWebhookSignature(int $timestamp, string $token, string $signature): bool @@ -73,7 +73,7 @@ public function verifyWebhookSignature(int $timestamp, string $token, string $si } /** - * @param string $domain + * @param string $domain * @return IndexResponse|ResponseInterface * @throws ClientExceptionInterface */ @@ -86,8 +86,8 @@ public function index(string $domain) } /** - * @param string $domain - * @param string $webhook + * @param string $domain + * @param string $webhook * @return ShowResponse|ResponseInterface * @throws ClientExceptionInterface */ @@ -101,9 +101,9 @@ public function show(string $domain, string $webhook) } /** - * @param string $domain - * @param string $id - * @param array $url + * @param string $domain + * @param string $id + * @param array $url * @return CreateResponse|ResponseInterface * @throws ClientExceptionInterface */ @@ -124,9 +124,9 @@ public function create(string $domain, string $id, array $url) } /** - * @param string $domain - * @param string $id - * @param array $url + * @param string $domain + * @param string $id + * @param array $url * @return UpdateResponse|ResponseInterface * @throws ClientExceptionInterface */ @@ -146,8 +146,8 @@ public function update(string $domain, string $id, array $url) } /** - * @param string $domain - * @param string $id + * @param string $domain + * @param string $id * @return DeleteResponse|ResponseInterface * @throws ClientExceptionInterface */ diff --git a/src/Model/EmailValidationV4/Job.php b/src/Model/EmailValidationV4/Job.php index 53beb32d..be67fdaa 100755 --- a/src/Model/EmailValidationV4/Job.php +++ b/src/Model/EmailValidationV4/Job.php @@ -59,7 +59,7 @@ final private function __construct() } /** - * @param array $data + * @param array $data * @return static */ public static function create(array $data): self From 37b0fd40812e9e534e8c3520660caa62609d0d3e Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sun, 9 Apr 2023 14:48:09 +0300 Subject: [PATCH 4/6] Fix code style --- src/Api/Event.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Api/Event.php b/src/Api/Event.php index 69248ebb..7c3943da 100644 --- a/src/Api/Event.php +++ b/src/Api/Event.php @@ -25,10 +25,12 @@ class Event extends HttpApi use Pagination; /** + * @param string $domain + * @param array $params * @return EventResponse * @throws ClientExceptionInterface */ - public function get(string $domain, array $params = []): EventResponse + public function get(string $domain, array $params = []) { Assert::stringNotEmpty($domain); From d808ee257ef0d2aaefa038a4a1158ddaabfb4d48 Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sun, 9 Apr 2023 14:48:22 +0300 Subject: [PATCH 5/6] Fix code style --- src/Api/Event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/Event.php b/src/Api/Event.php index 7c3943da..c158adc9 100644 --- a/src/Api/Event.php +++ b/src/Api/Event.php @@ -25,8 +25,8 @@ class Event extends HttpApi use Pagination; /** - * @param string $domain - * @param array $params + * @param string $domain + * @param array $params * @return EventResponse * @throws ClientExceptionInterface */ From c3cc65f5920138af46699015958d14604020459d Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sun, 9 Apr 2023 15:00:18 +0300 Subject: [PATCH 6/6] Fix code style --- src/Api/Pagination.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Pagination.php b/src/Api/Pagination.php index f3b262b0..2640adcd 100644 --- a/src/Api/Pagination.php +++ b/src/Api/Pagination.php @@ -69,7 +69,7 @@ public function lastPage(PagingProvider $response): ?PagingProvider /** * @param string $url - * @param string $class + * @param class-string $class * @return PagingProvider|null * @throws ClientExceptionInterface */