Skip to content

Commit de61758

Browse files
committed
Resolve git conflict
2 parents 6069b69 + 87b709c commit de61758

11 files changed

+52
-38
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
vendor/
22
phpcs.xml
33
phpunit.xml
4-
composer.lock
4+
composer.lock

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Latest Stable Version](https://img.shields.io/packagist/v/ddrv/mailer.svg?style=flat-square)](https://packagist.org/packages/ddrv/mailer)
22
[![Total Downloads](https://img.shields.io/packagist/dt/ddrv/mailer.svg?style=flat-square)](https://packagist.org/packages/ddrv/mailer/stats)
3-
[![License](https://img.shields.io/packagist/l/ddrv/mailer.svg?style=flat-square)](https://github.com/ddrv/mailer/blob/master/LICENSE)
3+
[![License](https://img.shields.io/packagist/l/ddrv/mailer.svg?style=flat-square)](https://github.com/ddrv/php-mailer/blob/master/LICENSE)
44
[![PHP](https://img.shields.io/packagist/php-v/ddrv/mailer.svg?style=flat-square)](https://php.net)
55

66

@@ -223,4 +223,4 @@ $transport = TransportFactory::make('file:////path/to/mail/files');
223223
// fake
224224
$transport = TransportFactory::make('fake://localhost');
225225

226-
```
226+
```

src/Exception/RecipientsListEmptyException.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
namespace Ddrv\Mailer\Exception;
44

55
use Exception;
6-
use Throwable;
76

87
final class RecipientsListEmptyException extends Exception
98
{
109

11-
public function __construct(Throwable $previous = null)
10+
public function __construct()
1211
{
13-
parent::__construct("recipients list is empty", 1, $previous);
12+
parent::__construct("recipients list is empty", 1);
1413
}
1514
}

src/Mailer.php

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

33
namespace Ddrv\Mailer;
44

5-
use Throwable;
5+
use Exception;
66

77
final class Mailer
88
{
99

10-
const MAILER_VERSION = "4.1.0";
10+
const MAILER_VERSION = "4.1.4";
1111

1212
/**
1313
* @var SpoolInterface
@@ -83,7 +83,7 @@ private function sendMail(Message $message, $personal = false, $priority = 1)
8383
ksort($params);
8484
try {
8585
call_user_func_array($fn, $params);
86-
} catch (Throwable $e) {
86+
} catch (Exception $e) {
8787
}
8888
}
8989
return $this;

src/Transport/FakeTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
final class FakeTransport implements TransportInterface
1111
{
1212
/**
13-
* @var callable
13+
* @var Closure
1414
*/
1515
private $logger;
1616

src/Transport/FileTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
final class FileTransport implements TransportInterface
1111
{
1212
/**
13-
* @var callable
13+
* @var Closure
1414
*/
1515
private $logger;
1616

src/Transport/SendmailTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class SendmailTransport implements TransportInterface
1616
private $options;
1717

1818
/**
19-
* @var callable
19+
* @var Closure
2020
*/
2121
private $logger;
2222

src/Transport/SmtpTransport.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class SmtpTransport implements TransportInterface
2525
private $email;
2626

2727
/**
28-
* @var callable
28+
* @var Closure
2929
*/
3030
private $logger;
3131

@@ -152,7 +152,9 @@ private function smtpCommand($command)
152152

153153
public function __destruct()
154154
{
155-
$this->smtpCommand("QUIT");
156-
fclose($this->socket);
155+
if (is_resource($this->socket)) {
156+
$this->smtpCommand("QUIT");
157+
fclose($this->socket);
158+
}
157159
}
158160
}

tests/Support/Factory/MessageFactory.php

+28-12
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,41 @@ public function __construct()
2525
public function generateMessage($toQuantity, $ccQuantity = 0, $bccQuantity = 0)
2626
{
2727
$toQuantity = (int)$toQuantity;
28-
if ($toQuantity < 1) $toQuantity = 1;
29-
if ($toQuantity > 20) $toQuantity = 20;
28+
if ($toQuantity < 1) {
29+
$toQuantity = 1;
30+
}
31+
if ($toQuantity > 20) {
32+
$toQuantity = 20;
33+
}
3034
$ccQuantity = (int)$ccQuantity;
31-
if ($ccQuantity < 0) $ccQuantity = 0;
32-
if ($ccQuantity > 20) $ccQuantity = 20;
35+
if ($ccQuantity < 0) {
36+
$ccQuantity = 0;
37+
}
38+
if ($ccQuantity > 20) {
39+
$ccQuantity = 20;
40+
}
3341
$bccQuantity = (int)$bccQuantity;
34-
if ($bccQuantity < 0) $bccQuantity = 0;
35-
if ($bccQuantity > 20) $bccQuantity = 20;
42+
if ($bccQuantity < 0) {
43+
$bccQuantity = 0;
44+
}
45+
if ($bccQuantity > 20) {
46+
$bccQuantity = 20;
47+
}
3648
$all = $toQuantity + $ccQuantity + $bccQuantity;
3749
$recipients = $this->generateRecipients($all);
3850

3951
$subject = $this->faker->text(50);
4052
$text = $this->faker->randomHtml();
4153
$message = new Message($subject, $text, true);
42-
for ($n=1; $n<=$toQuantity; $n++) {
54+
for ($n = 1; $n <= $toQuantity; $n++) {
4355
$recipient = array_shift($recipients);
4456
$message->addTo($recipient["email"], $recipient["name"]);
4557
}
46-
for ($n=1; $n<=$ccQuantity; $n++) {
58+
for ($n = 1; $n <= $ccQuantity; $n++) {
4759
$recipient = array_shift($recipients);
4860
$message->addCc($recipient["email"], $recipient["name"]);
4961
}
50-
for ($n=1; $n<=$bccQuantity; $n++) {
62+
for ($n = 1; $n <= $bccQuantity; $n++) {
5163
$recipient = array_shift($recipients);
5264
$message->addBcc($recipient["email"], $recipient["name"]);
5365
}
@@ -58,8 +70,12 @@ public function generateMessage($toQuantity, $ccQuantity = 0, $bccQuantity = 0)
5870
public function generateRecipients($quantity)
5971
{
6072
$quantity = (int)$quantity;
61-
if ($quantity < 1) $quantity = 1;
62-
if ($quantity > 100) $quantity = 100;
73+
if ($quantity < 1) {
74+
$quantity = 1;
75+
}
76+
if ($quantity > 100) {
77+
$quantity = 100;
78+
}
6379
$recipients = array();
6480
do {
6581
$email = $this->faker->email;
@@ -72,4 +88,4 @@ public function generateRecipients($quantity)
7288
} while (count($recipients) < $quantity);
7389
return $recipients;
7490
}
75-
}
91+
}

tests/Support/Mock/Transport/MockTransport.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
final class MockTransport implements TransportInterface
1111
{
1212
/**
13-
* @var callable
13+
* @var Closure
1414
*/
1515
private $logger;
1616

@@ -47,4 +47,4 @@ public function count()
4747
{
4848
return count($this->messages);
4949
}
50-
}
50+
}

tests/Unit/MailerTest.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ public function setUp()
3232
parent::setUp();
3333
$this->factory = new MessageFactory();
3434
$this->transport = new MockTransport();
35-
$this->transport->setLogger(function($log) {
36-
echo $log.PHP_EOL.PHP_EOL.PHP_EOL.PHP_EOL;
37-
});
3835
$this->mailer = new Mailer(new MemorySpool($this->transport));
3936
}
4037

@@ -92,17 +89,17 @@ public function testSpoolPersonalSend()
9289
private function generateMessages($quantity)
9390
{
9491
$messages = array();
95-
for ($i=1; $i<=$quantity; $i++) {
96-
$messages[] = $this->factory->generateMessage(rand(1,20), rand(1,20), rand(1,20));
92+
for ($i = 1; $i <= $quantity; $i++) {
93+
$messages[] = $this->factory->generateMessage(rand(1, 20), rand(1, 20), rand(1, 20));
9794
}
9895
return $messages;
9996
}
10097

10198
public static function assertMessage(Message $expected, Message $actual)
10299
{
103-
self::assertSame($expected->getSubject(), $actual->getSubject());
104-
self::assertSame($expected->getBody(), $actual->getBody());
105-
self::assertSame($expected->getHeaders(), $actual->getHeaders());
100+
self::assertSame($expected->getSubject(), $actual->getSubject());
101+
self::assertSame($expected->getBody(), $actual->getBody());
102+
self::assertSame($expected->getHeaders(), $actual->getHeaders());
106103
self::assertSame($expected->getRecipients(), $actual->getRecipients());
107104
}
108-
}
105+
}

0 commit comments

Comments
 (0)