Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request ericmartel#3 from oqq/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
oqq authored Oct 20, 2021
2 parents c74d986 + 0dbbc62 commit 6bbe2e4
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 58 deletions.
1 change: 0 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.3"
- "7.4"
- "8.0"
dependencies:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
vendor/
.php_cs.cache
.php-cs-fixer.php
.php-cs-fixer.cache
.phpunit.result.cache
composer.lock
phpunit.xml
27 changes: 27 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

$config = new class extends PhpCsFixer\Config
{
public function getRules(): array
{
$rules = parent::getRules();
$rules['concat_space'] = ['spacing' => 'one'];
$rules['phpdoc_align'] = false;
$rules['phpdoc_to_comment'] = false;
$rules['header_comment'] = false;

return $rules;
}
};

$config->getFinder()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

$config->setCacheFile(__DIR__ . '/.php-cs-fixer.cache');

return $config;
14 changes: 0 additions & 14 deletions .php_cs

This file was deleted.

8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
}
],
"require": {
"php": "7.3.* | 7.4.* | 8.0.*",
"php": "7.4.* | 8.0.*",
"ext-json": "*",
"ericmartel/codeception-email": "^1.0.3",
"guzzlehttp/guzzle": "^6.1 | ^7.0"
},
"require-dev": {
"codeception/codeception": "^4.0",
"friendsofphp/php-cs-fixer": "^2.15",
"phpunit/phpunit": "^8.0",
"roave/security-advisories": "dev-master"
"friendsofphp/php-cs-fixer": "^3.0",
"phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-latest"
},
"suggest": {
"ext-iconv": "Will be used as a mime decoder (iconv_mime_decode)",
Expand Down
17 changes: 0 additions & 17 deletions phpunit.xml

This file was deleted.

19 changes: 19 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
resolveDependencies="true"
executionOrder="random"
>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Main">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>
45 changes: 25 additions & 20 deletions src/MailHog.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,29 +445,34 @@ protected function getEmailPriority($email): string
*/
protected function getDecodedEmailProperty($email, $property): string
{
if ((string) $property !== '') {
if (!empty($email->Content->Headers->{'Content-Transfer-Encoding'}) && in_array(
'quoted-printable',
$email->Content->Headers->{'Content-Transfer-Encoding'},
true
)
) {
$property = quoted_printable_decode($property);
}
if (!empty($email->Content->Headers->{'Content-Type'}[0]) &&
strpos($email->Content->Headers->{'Content-Type'}[0], 'multipart/mixed') !== false
) {
$property = quoted_printable_decode($property);
if ($property !== '') {
return $property;
}

if (stripos($property, '=?utf-8?Q?') !== false) {
if (extension_loaded('iconv')) {
return iconv_mime_decode($property);
}
if (stripos($property, '=?utf-8?Q?') !== false) {
if (extension_loaded('iconv')) {
$property = iconv_mime_decode($property);
} elseif (extension_loaded('mbstring')) {
$property = mb_decode_mimeheader($property);
}
if (extension_loaded('mbstring')) {
return mb_decode_mimeheader($property);
}
}

if (!empty($email->Content->Headers->{'Content-Transfer-Encoding'}) && in_array(
'quoted-printable',
$email->Content->Headers->{'Content-Transfer-Encoding'},
true
)
) {
return quoted_printable_decode($property);
}

if (!empty($email->Content->Headers->{'Content-Type'}[0]) &&
strpos($email->Content->Headers->{'Content-Type'}[0], 'multipart/mixed') !== false
) {
return quoted_printable_decode($property);
}

return $property;
}

Expand Down Expand Up @@ -537,4 +542,4 @@ protected static function sortEmailsByCreationDatePredicate($emailA, $emailB): i

return ($sortKeyA > $sortKeyB) ? -1 : 1;
}
}
}
2 changes: 1 addition & 1 deletion tests/MailHogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,4 @@ public function getPropOpenedEmail()
$this->mailHog = $mailHog;
$this->mailHog->_initialize();
}
}
}

0 comments on commit 6bbe2e4

Please sign in to comment.