Skip to content

Commit 7d81dfa

Browse files
committed
Laravel 10
1 parent dbbb026 commit 7d81dfa

File tree

4 files changed

+16
-69
lines changed

4 files changed

+16
-69
lines changed

.php_cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"description": "Aliyun DrirectMail Transport for Laravel Application.",
44
"type": "library",
55
"require": {
6-
"guzzlehttp/guzzle": "^6.3 || ^7.0",
7-
"laravel/framework": "^7.0 || ^8.0",
6+
"guzzlehttp/guzzle": "^7.0",
7+
"laravel/framework": "^9.0|^10.0",
88
"swiftmailer/swiftmailer": "^6.1"
99
},
1010
"license": "MIT",
@@ -21,7 +21,12 @@
2121
},
2222
"extra": {
2323
"laravel": {
24-
"providers": ["Overtrue\\LaravelMailAliyun\\DirectMailServiceProvider"]
24+
"providers": [
25+
"Overtrue\\LaravelMailAliyun\\DirectMailServiceProvider"
26+
]
2527
}
28+
},
29+
"require-dev": {
30+
"laravel/pint": "^1.5"
2631
}
2732
}

src/DirectMailTransport.php

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ class DirectMailTransport extends Transport
6464

6565
/**
6666
* DirectMailTransport constructor.
67-
*
68-
* @param \GuzzleHttp\ClientInterface $client
69-
* @param string $key
70-
* @param string $secret
71-
* @param array $options
7267
*/
7368
public function __construct(ClientInterface $client, string $key, string $secret, array $options = [])
7469
{
@@ -84,9 +79,7 @@ public function __construct(ClientInterface $client, string $key, string $secret
8479
* Recipient/sender data will be retrieved from the Message API.
8580
* The return value is the number of recipients who were accepted for delivery.
8681
*
87-
* @param Swift_Mime_SimpleMessage $message
88-
* @param string[] $failedRecipients An array of failures by-reference
89-
*
82+
* @param string[] $failedRecipients An array of failures by-reference
9083
* @return int
9184
*/
9285
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
@@ -108,8 +101,6 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
108101
/**
109102
* Get the HTTP payload for sending the message.
110103
*
111-
* @param \Swift_Mime_SimpleMessage $message
112-
* @param array $region
113104
*
114105
* @return array
115106
*/
@@ -132,7 +123,7 @@ protected function payload(Swift_Mime_SimpleMessage $message, array $region)
132123
'SignatureVersion' => '1.0',
133124
'SignatureNonce' => \uniqid(),
134125
'RegionId' => $region['id'],
135-
'TagName' => $this->getTagName($message)
126+
'TagName' => $this->getTagName($message),
136127
]);
137128

138129
$bodyName = $this->getBodyName($message);
@@ -144,8 +135,6 @@ protected function payload(Swift_Mime_SimpleMessage $message, array $region)
144135
}
145136

146137
/**
147-
* @param array $parameters
148-
*
149138
* @return string
150139
*/
151140
protected function makeSignature(array $parameters)
@@ -158,28 +147,25 @@ protected function makeSignature(array $parameters)
158147
$encoded[] = \sprintf('%s=%s', rawurlencode($key), rawurlencode($value));
159148
}
160149

161-
$signString = 'POST&%2F&' . rawurlencode(\join('&', $encoded));
150+
$signString = 'POST&%2F&'.rawurlencode(\implode('&', $encoded));
162151

163-
return base64_encode(hash_hmac('sha1', $signString, $this->getSecret() . '&', true));
152+
return base64_encode(hash_hmac('sha1', $signString, $this->getSecret().'&', true));
164153
}
165154

166155
/**
167156
* Get the "to" payload field for the API request.
168157
*
169-
* @param \Swift_Mime_SimpleMessage $message
170158
*
171159
* @return string
172160
*/
173161
protected function getTo(Swift_Mime_SimpleMessage $message)
174162
{
175163
return collect($this->allContacts($message))->map(function ($display, $address) {
176-
return $display ? $display . " <{$address}>" : $address;
164+
return $display ? $display." <{$address}>" : $address;
177165
})->values()->implode(',');
178166
}
179167

180168
/**
181-
* @param \Psr\Http\Message\ResponseInterface $response
182-
*
183169
* @return mixed
184170
*/
185171
protected function getTransmissionId(ResponseInterface $response)
@@ -191,8 +177,6 @@ protected function getTransmissionId(ResponseInterface $response)
191177
}
192178

193179
/**
194-
* @param \Swift_Mime_SimpleMessage $message
195-
*
196180
* @return array
197181
*/
198182
protected function allContacts(Swift_Mime_SimpleMessage $message)
@@ -221,8 +205,6 @@ public function getSecret()
221205
}
222206

223207
/**
224-
* @param string $key
225-
*
226208
* @return string
227209
*/
228210
public function setKey(string $key)
@@ -231,8 +213,6 @@ public function setKey(string $key)
231213
}
232214

233215
/**
234-
* @param string $secret
235-
*
236216
* @return string
237217
*/
238218
public function setSecret(string $secret)
@@ -241,8 +221,6 @@ public function setSecret(string $secret)
241221
}
242222

243223
/**
244-
* @param Swift_Mime_SimpleMessage $message
245-
*
246224
* @return string
247225
*/
248226
protected function getBodyName(Swift_Mime_SimpleMessage $message)
@@ -251,8 +229,6 @@ protected function getBodyName(Swift_Mime_SimpleMessage $message)
251229
}
252230

253231
/**
254-
* @param Swift_Mime_SimpleMessage $message
255-
*
256232
* @return string|null
257233
*/
258234
protected function getTagName(Swift_Mime_SimpleMessage $message)

src/HasTagName.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace Overtrue\LaravelMailAliyun;
54

65
use Illuminate\Mail\Mailable;
@@ -14,8 +13,7 @@
1413
trait HasTagName
1514
{
1615
/**
17-
* @param string $tagName
18-
*
16+
* @param string $tagName
1917
* @return \Closure
2018
*/
2119
protected function getMailableCallback($tagName)
@@ -26,15 +24,15 @@ protected function getMailableCallback($tagName)
2624
}
2725

2826
/**
29-
* @param string $tagName
30-
*
27+
* @param string $tagName
3128
* @return $this
3229
*/
3330
public function tagName($tagName)
3431
{
3532
if ($this instanceof Mailable) {
3633
$this->withSwiftMessage($this->getMailableCallback($tagName));
3734
}
35+
3836
return $this;
3937
}
4038
}

0 commit comments

Comments
 (0)