Skip to content

Commit adfb9a8

Browse files
Merge pull request #5 from stackkit/analysis-zYmYl9
Apply fixes from StyleCI
2 parents 9de53fb + d9113f6 commit adfb9a8

19 files changed

+128
-129
lines changed

config/laravel-database-emails.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444

4545
'enabled' => function () {
4646
return false;
47-
// ...or...
47+
// ...or...
4848
// return app()->environment('local', 'staging');
49-
}
49+
},
5050

5151
],
5252

@@ -61,5 +61,5 @@
6161
|
6262
*/
6363

64-
'limit' => 20
64+
'limit' => 20,
6565
];

src/Email.php

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Buildcode\LaravelDatabaseEmails;
44

5-
use Illuminate\Database\Eloquent\Model;
6-
use Carbon\Carbon;
75
use Exception;
6+
use Carbon\Carbon;
7+
use Illuminate\Database\Eloquent\Model;
88

99
/**
1010
* @property $id
@@ -124,7 +124,7 @@ public function getRecipientsAsString()
124124
{
125125
$glue = ', ';
126126

127-
return implode($glue, (array)$this->recipient);
127+
return implode($glue, (array) $this->recipient);
128128
}
129129

130130
/**
@@ -164,7 +164,6 @@ public function getSubject()
164164
*/
165165
public function getView()
166166
{
167-
168167
return $this->view;
169168
}
170169

@@ -225,7 +224,7 @@ public function getScheduledDate()
225224
*/
226225
public function hasVariables()
227226
{
228-
return !is_null($this->variables);
227+
return ! is_null($this->variables);
229228
}
230229

231230
/**
@@ -299,7 +298,7 @@ public function hasBcc()
299298
*/
300299
public function isScheduled()
301300
{
302-
return !is_null($this->getScheduledDate());
301+
return ! is_null($this->getScheduledDate());
303302
}
304303

305304
/**
@@ -309,7 +308,7 @@ public function isScheduled()
309308
*/
310309
public function isEncrypted()
311310
{
312-
return !!$this->getOriginal('encrypted');
311+
return (bool) $this->getOriginal('encrypted');
313312
}
314313

315314
/**
@@ -319,7 +318,7 @@ public function isEncrypted()
319318
*/
320319
public function isSent()
321320
{
322-
return !is_null($this->sent_at);
321+
return ! is_null($this->sent_at);
323322
}
324323

325324
/**
@@ -373,7 +372,7 @@ public function markAsFailed(Exception $exception)
373372
$this->update([
374373
'sending' => 0,
375374
'failed' => 1,
376-
'error' => (string)$exception,
375+
'error' => (string) $exception,
377376
]);
378377
}
379378

src/EmailComposer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function setData($key, $value)
6363
*/
6464
public function getData($key, $default = null)
6565
{
66-
if (!is_null($default) && !$this->hasData($key)) {
66+
if (! is_null($default) && ! $this->hasData($key)) {
6767
return $default;
6868
}
6969

src/Encrypter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function encryptSubject(EmailComposer $composer)
8585
*/
8686
private function encryptVariables(EmailComposer $composer)
8787
{
88-
if (!$composer->hasData('variables')) {
88+
if (! $composer->hasData('variables')) {
8989
return;
9090
}
9191

src/HasEncryptedAttributes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getAttribute($key)
5656
if (in_array($key, $this->encoded) && is_string($value)) {
5757
$decoded = json_decode($value, true);
5858

59-
if (!is_null($decoded)) {
59+
if (! is_null($decoded)) {
6060
$value = $decoded;
6161
}
6262
}

src/MailableReader.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Buildcode\LaravelDatabaseEmails;
44

5-
use function call_user_func_array;
65
use Exception;
6+
use function call_user_func_array;
77

88
class MailableReader
99
{
@@ -135,11 +135,11 @@ private function readAttachments(EmailComposer $composer)
135135
{
136136
$mailable = $composer->getData('mailable');
137137

138-
foreach ((array)$mailable->attachments as $attachment) {
138+
foreach ((array) $mailable->attachments as $attachment) {
139139
call_user_func_array([$composer, 'attach'], $attachment);
140140
}
141141

142-
foreach ((array)$mailable->rawAttachments as $rawAttachment) {
142+
foreach ((array) $mailable->rawAttachments as $rawAttachment) {
143143
call_user_func_array([$composer, 'attachData'], $rawAttachment);
144144
}
145145
}

src/Preparer.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function prepare(EmailComposer $composer)
4343
*/
4444
private function prepareLabel(EmailComposer $composer)
4545
{
46-
if (!$composer->hasData('label')) {
46+
if (! $composer->hasData('label')) {
4747
return;
4848
}
4949

5050
$composer->getEmail()->fill([
51-
'label' => $composer->getData('label')
51+
'label' => $composer->getData('label'),
5252
]);
5353
}
5454

@@ -143,7 +143,7 @@ private function prepareView(EmailComposer $composer)
143143
*/
144144
private function prepareVariables(EmailComposer $composer)
145145
{
146-
if (!$composer->hasData('variables')) {
146+
if (! $composer->hasData('variables')) {
147147
return;
148148
}
149149

@@ -181,14 +181,14 @@ private function prepareAttachments(EmailComposer $composer)
181181
{
182182
$attachments = [];
183183

184-
foreach ((array)$composer->getData('attachments', []) as $attachment) {
184+
foreach ((array) $composer->getData('attachments', []) as $attachment) {
185185
$attachments[] = [
186186
'type' => 'attachment',
187187
'attachment' => $attachment,
188188
];
189189
}
190190

191-
foreach ((array)$composer->getData('rawAttachments', []) as $rawAttachment) {
191+
foreach ((array) $composer->getData('rawAttachments', []) as $rawAttachment) {
192192
$attachments[] = [
193193
'type' => 'rawAttachment',
194194
'attachment' => $rawAttachment,
@@ -207,7 +207,7 @@ private function prepareAttachments(EmailComposer $composer)
207207
*/
208208
private function prepareScheduled(EmailComposer $composer)
209209
{
210-
if (!$composer->hasData('scheduled_at')) {
210+
if (! $composer->hasData('scheduled_at')) {
211211
return;
212212
}
213213

src/RetryFailedEmailsCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(Store $store)
4646
*/
4747
public function handle()
4848
{
49-
if (get_class($this) === RetryFailedEmailsCommand::class) {
49+
if (get_class($this) === self::class) {
5050
$this->warn('This command is deprecated, please use email:resend instead');
5151
}
5252

@@ -56,6 +56,7 @@ public function handle()
5656

5757
if ($emails->isEmpty()) {
5858
$this->line('There is nothing to reset.');
59+
5960
return;
6061
}
6162

src/SendEmailsCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Buildcode\LaravelDatabaseEmails;
44

5-
use Illuminate\Console\Command;
65
use Exception;
6+
use Illuminate\Console\Command;
77
use Illuminate\Database\Eloquent\Collection;
88

99
class SendEmailsCommand extends Command
@@ -54,6 +54,7 @@ public function handle()
5454

5555
if ($emails->isEmpty()) {
5656
$this->line('There is nothing to send.');
57+
5758
return;
5859
}
5960

src/Sender.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private function buildMessage(Message $message, Email $email)
5757
'rawAttachment' => 'attachData',
5858
];
5959

60-
foreach ((array)$email->getAttachments() as $attachment) {
60+
foreach ((array) $email->getAttachments() as $attachment) {
6161
call_user_func_array([$message, $attachmentMap[$attachment['type']]], $attachment['attachment']);
6262
}
6363
}

src/Validator.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Buildcode\LaravelDatabaseEmails;
44

5+
use Exception;
56
use Carbon\Carbon;
67
use InvalidArgumentException;
7-
use Exception;
88

99
class Validator
1010
{
@@ -61,14 +61,14 @@ private function validateLabel(EmailComposer $composer)
6161
*/
6262
private function validateRecipient(EmailComposer $composer)
6363
{
64-
if (!$composer->hasData('recipient')) {
64+
if (! $composer->hasData('recipient')) {
6565
throw new InvalidArgumentException('No recipient specified');
6666
}
6767

68-
$recipients = (array)$composer->getData('recipient');
68+
$recipients = (array) $composer->getData('recipient');
6969

7070
foreach ($recipients as $recipient) {
71-
if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
71+
if (! filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
7272
throw new InvalidArgumentException('E-mail address [' . $recipient . '] is invalid');
7373
}
7474
}
@@ -82,12 +82,12 @@ private function validateRecipient(EmailComposer $composer)
8282
*/
8383
private function validateCc(EmailComposer $composer)
8484
{
85-
if (!$composer->hasData('cc')) {
85+
if (! $composer->hasData('cc')) {
8686
return;
8787
}
8888

89-
foreach ((array)$composer->getData('cc') as $cc) {
90-
if (!filter_var($cc, FILTER_VALIDATE_EMAIL)) {
89+
foreach ((array) $composer->getData('cc') as $cc) {
90+
if (! filter_var($cc, FILTER_VALIDATE_EMAIL)) {
9191
throw new InvalidArgumentException('E-mail address [' . $cc . '] is invalid');
9292
}
9393
}
@@ -101,12 +101,12 @@ private function validateCc(EmailComposer $composer)
101101
*/
102102
private function validateBcc(EmailComposer $composer)
103103
{
104-
if (!$composer->hasData('bcc')) {
104+
if (! $composer->hasData('bcc')) {
105105
return;
106106
}
107107

108-
foreach ((array)$composer->getData('bcc') as $bcc) {
109-
if (!filter_var($bcc, FILTER_VALIDATE_EMAIL)) {
108+
foreach ((array) $composer->getData('bcc') as $bcc) {
109+
if (! filter_var($bcc, FILTER_VALIDATE_EMAIL)) {
110110
throw new InvalidargumentException('E-mail address [' . $bcc . '] is invalid');
111111
}
112112
}
@@ -120,7 +120,7 @@ private function validateBcc(EmailComposer $composer)
120120
*/
121121
private function validateSubject(EmailComposer $composer)
122122
{
123-
if (!$composer->hasData('subject')) {
123+
if (! $composer->hasData('subject')) {
124124
throw new InvalidArgumentException('No subject specified');
125125
}
126126
}
@@ -137,13 +137,13 @@ private function validateView(EmailComposer $composer)
137137
return;
138138
}
139139

140-
if (!$composer->hasData('view')) {
140+
if (! $composer->hasData('view')) {
141141
throw new InvalidArgumentException('No view specified');
142142
}
143143

144144
$view = $composer->getData('view');
145145

146-
if (!view()->exists($view)) {
146+
if (! view()->exists($view)) {
147147
throw new InvalidArgumentException('View [' . $view . '] does not exist');
148148
}
149149
}
@@ -156,7 +156,7 @@ private function validateView(EmailComposer $composer)
156156
*/
157157
private function validateVariables(EmailComposer $composer)
158158
{
159-
if ($composer->hasData('variables') && !is_array($composer->getData('variables'))) {
159+
if ($composer->hasData('variables') && ! is_array($composer->getData('variables'))) {
160160
throw new InvalidArgumentException('Variables must be an array');
161161
}
162162
}
@@ -169,13 +169,13 @@ private function validateVariables(EmailComposer $composer)
169169
*/
170170
private function validateScheduled(EmailComposer $composer)
171171
{
172-
if (!$composer->hasData('scheduled_at')) {
172+
if (! $composer->hasData('scheduled_at')) {
173173
return;
174174
}
175175

176176
$scheduled = $composer->getData('scheduled_at');
177177

178-
if (!$scheduled instanceof Carbon && !is_string($scheduled)) {
178+
if (! $scheduled instanceof Carbon && ! is_string($scheduled)) {
179179
throw new InvalidArgumentException('Scheduled date must be a Carbon\Carbon instance or a strtotime-valid string');
180180
}
181181

0 commit comments

Comments
 (0)