improve code
This commit is contained in:
parent
f9e040a671
commit
ed85f12b7f
@ -4,9 +4,25 @@ $finder = PhpCsFixer\Finder::create()
|
|||||||
->in(__DIR__)
|
->in(__DIR__)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$fileHeaderComment = <<<EOF
|
||||||
|
For the full copyright and license information, please view the LICENSE
|
||||||
|
file that was distributed with this source code.
|
||||||
|
|
||||||
|
https://www.d3data.de
|
||||||
|
|
||||||
|
@copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
|
@author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||||
|
@link https://www.oxidmodule.com
|
||||||
|
EOF;
|
||||||
|
|
||||||
$config = new PhpCsFixer\Config();
|
$config = new PhpCsFixer\Config();
|
||||||
return $config->setRules([
|
return $config->setRules([
|
||||||
'@PHP73Migration' => true,
|
'header_comment' => [
|
||||||
|
'header' => $fileHeaderComment,
|
||||||
|
'comment_type' => 'PHPDoc',
|
||||||
|
'location' => 'after_open'
|
||||||
|
],
|
||||||
|
'@PHP80Migration' => true,
|
||||||
'@PSR12' => true
|
'@PSR12' => true
|
||||||
])
|
])
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
|
@ -88,14 +88,14 @@ class MailConfigCheck extends AdminDetailsController
|
|||||||
protected function getCurrentMailer(): void
|
protected function getCurrentMailer(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$shop = Registry::getConfig()->getActiveShop();
|
$shop = Registry::getConfig()->getActiveShop();
|
||||||
|
|
||||||
$mail = oxNew(Email::class);
|
$mail = oxNew(Email::class);
|
||||||
$mail->setRecipient(
|
$mail->setRecipient(
|
||||||
trim(Registry::getRequest()->getRequestEscapedParameter('recipient')) ?: $this->testMailAddress
|
trim(Registry::getRequest()->getRequestEscapedParameter('recipient')) ?: $this->testMailAddress
|
||||||
);
|
);
|
||||||
$mail->setBody('.');
|
$mail->setBody('.');
|
||||||
$mail->setFrom($shop->getFieldData('oxowneremail'));
|
$mail->setFrom($shop->getFieldData('oxowneremail'));
|
||||||
|
|
||||||
$mail->set("SMTPDebug", true); // don't set via iDebug = 6 because different handling
|
$mail->set("SMTPDebug", true); // don't set via iDebug = 6 because different handling
|
||||||
$mail->setSmtp();
|
$mail->setSmtp();
|
||||||
|
@ -46,7 +46,7 @@ class MailTester extends AdminDetailsController
|
|||||||
$mail->setFrom($from);
|
$mail->setFrom($from);
|
||||||
$mail->sendEmail($to, $subject, $body);
|
$mail->sendEmail($to, $subject, $body);
|
||||||
$this->addTplParam('success', true);
|
$this->addTplParam('success', true);
|
||||||
} catch ( Exception $e) {
|
} catch (Exception $e) {
|
||||||
Registry::getUtilsView()->addErrorToDisplay(nl2br($e->getMessage()));
|
Registry::getUtilsView()->addErrorToDisplay(nl2br($e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class SpfChecker extends AdminDetailsController
|
|||||||
function ($mailAddress) {
|
function ($mailAddress) {
|
||||||
$mailAddress = trim($mailAddress);
|
$mailAddress = trim($mailAddress);
|
||||||
try {
|
try {
|
||||||
if ( ! str_contains( $mailAddress, '@' ) ) {
|
if (! str_contains($mailAddress, '@')) {
|
||||||
throw oxNew(InvalidArgumentException::class);
|
throw oxNew(InvalidArgumentException::class);
|
||||||
}
|
}
|
||||||
$addressChunks = explode('@', $mailAddress);
|
$addressChunks = explode('@', $mailAddress);
|
||||||
@ -107,7 +107,7 @@ class SpfChecker extends AdminDetailsController
|
|||||||
$query = new Query('', $domain);
|
$query = new Query('', $domain);
|
||||||
|
|
||||||
$result = $checker->getResult($query);
|
$result = $checker->getResult($query);
|
||||||
$status = match ( $result->getResult() ) {
|
$status = match ($result->getResult()) {
|
||||||
Result::FAIL, Result::NEUTRAL, Result::PASS, Result::SOFTFAIL => SpfResult::SET,
|
Result::FAIL, Result::NEUTRAL, Result::PASS, Result::SOFTFAIL => SpfResult::SET,
|
||||||
Result::NONE => SpfResult::MISSING,
|
Result::NONE => SpfResult::MISSING,
|
||||||
default => SpfResult::ERROR,
|
default => SpfResult::ERROR,
|
||||||
@ -122,7 +122,7 @@ class SpfChecker extends AdminDetailsController
|
|||||||
|
|
||||||
public function getSpfStatusColor(SpfResult $result): string
|
public function getSpfStatusColor(SpfResult $result): string
|
||||||
{
|
{
|
||||||
return match ( $result->getStatus() ) {
|
return match ($result->getStatus()) {
|
||||||
SpfResult::SET => 'success',
|
SpfResult::SET => 'success',
|
||||||
SpfResult::ERROR => 'warning',
|
SpfResult::ERROR => 'warning',
|
||||||
default => 'danger',
|
default => 'danger',
|
||||||
@ -136,21 +136,21 @@ class SpfChecker extends AdminDetailsController
|
|||||||
$query = new Query('', $domain);
|
$query = new Query('', $domain);
|
||||||
$record = $check->getResult($query)->getRecord();
|
$record = $check->getResult($query)->getRecord();
|
||||||
|
|
||||||
$status = match ( $record->getRejectPolicy()->getValue() ) {
|
$status = match ($record->getRejectPolicy()->getValue()) {
|
||||||
DMARCResult::REJECT_QUARANTINE, DMARCResult::REJECT_REJECT => OxDmarcResult::SET,
|
DMARCResult::REJECT_QUARANTINE, DMARCResult::REJECT_REJECT => OxDmarcResult::SET,
|
||||||
DMARCResult::REJECT_NONE => OxDmarcResult::MISSING,
|
DMARCResult::REJECT_NONE => OxDmarcResult::MISSING,
|
||||||
default => OxDmarcResult::ERROR,
|
default => OxDmarcResult::ERROR,
|
||||||
};
|
};
|
||||||
|
|
||||||
$summarize[$domain] = oxNew( OxDmarcResult::class, $status, $record->getRawRecord());
|
$summarize[$domain] = oxNew(OxDmarcResult::class, $status, $record->getRawRecord());
|
||||||
} catch ( LogicException) {
|
} catch (LogicException) {
|
||||||
$summarize[$domain] = oxNew( OxDmarcResult::class, OxDmarcResult::MISSING, '');
|
$summarize[$domain] = oxNew(OxDmarcResult::class, OxDmarcResult::MISSING, '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDmarcStatusColor(OxDmarcResult $result): string
|
public function getDmarcStatusColor(OxDmarcResult $result): string
|
||||||
{
|
{
|
||||||
return match ( $result->getStatus() ) {
|
return match ($result->getStatus()) {
|
||||||
SpfResult::SET => 'success',
|
SpfResult::SET => 'success',
|
||||||
SpfResult::ERROR => 'warning',
|
SpfResult::ERROR => 'warning',
|
||||||
default => 'danger',
|
default => 'danger',
|
||||||
|
@ -21,8 +21,8 @@ class DmarcResult
|
|||||||
public const MISSING = 'missing';
|
public const MISSING = 'missing';
|
||||||
public const ERROR = 'error';
|
public const ERROR = 'error';
|
||||||
|
|
||||||
protected $status;
|
protected string $status;
|
||||||
protected $record;
|
protected ?string $record;
|
||||||
|
|
||||||
public function __construct(string $status, ?string $record = null)
|
public function __construct(string $status, ?string $record = null)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ class d3TranslatableLazyAssertionException extends LazyAssertionException
|
|||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
$message .= sprintf("%d) %s: %s\n", $i ++, $error->getPropertyPath(), $error->getMessage());
|
$message .= sprintf("%d) %s: %s\n", $i++, $error->getPropertyPath(), $error->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LazyAssertionException($message, $errors);
|
return new LazyAssertionException($message, $errors);
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
"beberlei/assert": "^3.3"
|
"beberlei/assert": "^3.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"php": "^8",
|
|
||||||
"friendsofphp/php-cs-fixer": "^3.9",
|
"friendsofphp/php-cs-fixer": "^3.9",
|
||||||
"phpstan/phpstan": "^1.8",
|
"phpstan/phpstan": "^1.8",
|
||||||
"boxblinkracer/phpunuhi": "^1.12"
|
"boxblinkracer/phpunuhi": "^1.12"
|
||||||
@ -50,6 +49,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --config=vendor/d3/mailconfigchecker/.php-cs-fixer.php",
|
||||||
"phpstan": "./vendor/bin/phpstan --configuration=./vendor/d3/mailconfigchecker/phpstan.neon",
|
"phpstan": "./vendor/bin/phpstan --configuration=./vendor/d3/mailconfigchecker/phpstan.neon",
|
||||||
"phpunuhi": "./vendor/bin/phpunuhi --configuration=vendor/d3/mailconfigchecker/phpunuhi.xml validate"
|
"phpunuhi": "./vendor/bin/phpunuhi --configuration=vendor/d3/mailconfigchecker/phpunuhi.xml validate"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user