From 44e024f3a8ea4b172664abc7ec5a08eb82bf347b Mon Sep 17 00:00:00 2001 From: Jonatas Souza Date: Sat, 20 Jan 2024 05:06:38 -0300 Subject: [PATCH] fix cs errors --- .gitignore | 1 + src/Builder/Buildable.php | 2 +- src/Builder/MailJobBuilder.php | 5 ++- src/Builder/QueueBuilder.php | 5 ++- src/Event/Event.php | 9 ++-- src/Event/EventHandlerTrait.php | 4 +- src/Exception/InvalidCallException.php | 1 + .../InvalidCallbackArgumentException.php | 1 + .../InvalidTransportTypeArgumentException.php | 1 + .../UndefinedMessageBrokerException.php | 1 - src/Exception/UnknownPropertyException.php | 1 + src/Helper/ArrayHelper.php | 2 +- src/Helper/PhpViewFileHelper.php | 2 +- src/Helper/RecipientsHelper.php | 1 + src/Mailer.php | 9 ++-- src/Model/AbstractMailObject.php | 1 + src/Model/MailJob.php | 10 ++--- src/Model/MailMessage.php | 28 ++++++------ .../Backend/AbstractQueueStoreConnection.php | 9 ++-- .../Backend/Beanstalkd/BeanstalkdMailJob.php | 6 +-- .../BeanstalkdQueueStoreAdapter.php | 39 +++++----------- .../BeanstalkdQueueStoreConnection.php | 3 +- src/Queue/Backend/MailJobInterface.php | 10 ++--- src/Queue/Backend/Pdo/PdoMailJob.php | 17 +++---- .../Backend/Pdo/PdoQueueStoreAdapter.php | 29 +++--------- .../Backend/Pdo/PdoQueueStoreConnection.php | 11 +---- .../Backend/QueueStoreAdapterInterface.php | 16 +++---- .../RabbitMq/RabbitMqQueueConnection.php | 1 - src/Queue/Backend/Redis/RedisMailJob.php | 8 ++-- .../Backend/Redis/RedisQueueStoreAdapter.php | 44 +++++++------------ .../Redis/RedisQueueStoreConnection.php | 2 +- src/Queue/Backend/Sqs/SqsMailJob.php | 13 +++--- .../Backend/Sqs/SqsQueueStoreAdapter.php | 18 +++----- .../Backend/Sqs/SqsQueueStoreConnection.php | 3 +- src/Queue/Cli/MailMessageWorker.php | 11 ++--- src/Security/Cypher.php | 11 ++--- src/Security/CypherInterface.php | 4 +- src/Transport/AbstractTransportFactory.php | 4 +- src/Transport/MailTransport.php | 3 +- src/Transport/MailTransportFactory.php | 1 + src/Transport/SendMailTransport.php | 6 +-- src/Transport/SendMailTransportFactory.php | 1 + src/Transport/SmtpTransport.php | 15 +++---- src/Transport/SmtpTransportFactory.php | 2 +- src/Transport/TransportFactory.php | 2 + 45 files changed, 152 insertions(+), 221 deletions(-) diff --git a/.gitignore b/.gitignore index 13d3253..9a8eb86 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ index .composer.lock .phpunit.cache composer.lock +PHP_CodeSniffer diff --git a/src/Builder/Buildable.php b/src/Builder/Buildable.php index ad25745..7c83e38 100644 --- a/src/Builder/Buildable.php +++ b/src/Builder/Buildable.php @@ -20,5 +20,5 @@ protected static function getConfig() * @param $config * @return void */ - public abstract static function make($config = null); + abstract public static function make($config = null); } diff --git a/src/Builder/MailJobBuilder.php b/src/Builder/MailJobBuilder.php index 13a0c14..43a9a91 100644 --- a/src/Builder/MailJobBuilder.php +++ b/src/Builder/MailJobBuilder.php @@ -24,7 +24,7 @@ public static function make($jobAttributes = null, ?string $broker = null): Mail $config = self::getConfig(); $messageBroker = $broker ?? $config['config']['message_broker']; - switch($messageBroker) { + switch ($messageBroker) { case MessageBrokerEnum::BROKER_REDIS: return new RedisMailJob($jobAttributes); case MessageBrokerEnum::BROKER_SQS: @@ -35,7 +35,8 @@ public static function make($jobAttributes = null, ?string $broker = null): Mail return new PdoMailJob($jobAttributes); case MessageBrokerEnum::BROKER_RABBITMQ: return new RabbitMqJob($jobAttributes); - default: throw new UndefinedMessageBrokerException(); + default: + throw new UndefinedMessageBrokerException(); } } } diff --git a/src/Builder/QueueBuilder.php b/src/Builder/QueueBuilder.php index 57f4154..40d1aa5 100644 --- a/src/Builder/QueueBuilder.php +++ b/src/Builder/QueueBuilder.php @@ -45,7 +45,7 @@ protected static function getBrokerAdapter($messageBroker) $config = self::getConfig(); $connectionValues = $config['brokers'][$messageBroker] ?? []; - switch($messageBroker) { + switch ($messageBroker) { case MessageBrokerEnum::BROKER_REDIS: return new RedisQueueStoreAdapter( new RedisQueueStoreConnection($connectionValues) @@ -66,7 +66,8 @@ protected static function getBrokerAdapter($messageBroker) return new RabbitMqQueueStoreAdapter( new RabbitMqQueueConnection($connectionValues) ); - default: throw new UndefinedMessageBrokerException(); + default: + throw new UndefinedMessageBrokerException(); } } } diff --git a/src/Event/Event.php b/src/Event/Event.php index a643179..907a507 100644 --- a/src/Event/Event.php +++ b/src/Event/Event.php @@ -1,4 +1,5 @@ data = func_get_args(); - return call_user_func($this->handler, $this); } diff --git a/src/Event/EventHandlerTrait.php b/src/Event/EventHandlerTrait.php index 1147219..be37bec 100644 --- a/src/Event/EventHandlerTrait.php +++ b/src/Event/EventHandlerTrait.php @@ -1,4 +1,5 @@ getTransportInstance()->send($message); } @@ -121,9 +120,7 @@ public static function fromMailMessage(MailMessage $mailMessage) 'port' => $mailMessage->port, 'options' => $mailMessage->transportOptions, ]; - $factory = TransportFactory::create($options, $mailMessage->transportType); - return new Mailer($factory->create()); } } diff --git a/src/Model/AbstractMailObject.php b/src/Model/AbstractMailObject.php index 5f5fb7a..86770d7 100644 --- a/src/Model/AbstractMailObject.php +++ b/src/Model/AbstractMailObject.php @@ -1,4 +1,5 @@ json_encode($this)]); - QueueBuilder::make()->enqueue($job); } @@ -131,7 +130,6 @@ public function addAttachment(string $path, ?string $name = null): void { if (is_null($this->attachments)) { $this->attachments = [File::make($path, $name)]; - return; } diff --git a/src/Queue/Backend/AbstractQueueStoreConnection.php b/src/Queue/Backend/AbstractQueueStoreConnection.php index e5267b6..74999b7 100644 --- a/src/Queue/Backend/AbstractQueueStoreConnection.php +++ b/src/Queue/Backend/AbstractQueueStoreConnection.php @@ -1,4 +1,5 @@ connection = $connection; $this->queueName = $queueName; $this->timeToRun = $timeToRun; @@ -58,7 +54,6 @@ public function __construct( public function init() { $this->getConnection()->connect(); - return $this; } @@ -80,7 +75,6 @@ public function enqueue(MailJobInterface $mailJob) $timestamp = $mailJob->getTimeToSend(); $payload = $this->createPayload($mailJob); $delay = (int) max(Pheanstalk::DEFAULT_DELAY, $timestamp - time()); - return $this->getConnection() ->getInstance() ->useTube($this->queueName) @@ -96,15 +90,12 @@ public function dequeue() $job = $this->getConnection()->getInstance()->watch($this->queueName)->reserveWithTimeout($this->reserveTimeout); if ($job instanceof PheanstalkJob) { $data = json_decode($job->getData(), true); - - return new BeanstalkdMailJob( - [ + return new BeanstalkdMailJob([ 'id' => $data['id'], 'attempt' => $data['attempt'], 'message' => $data['message'], 'pheanstalkJob' => $job, - ] - ); + ]); } return null; @@ -123,17 +114,14 @@ public function ack(MailJobInterface $mailJob) $pheanstalk = $this->getConnection()->getInstance()->useTube($this->queueName); if ($mailJob->isCompleted()) { $pheanstalk->delete($mailJob->getPheanstalkJob()); - return null; } $timestamp = $mailJob->getTimeToSend(); $delay = max(0, $timestamp - time()); - - // add back to the queue as it wasn't completed maybe due to some transitory error +// add back to the queue as it wasn't completed maybe due to some transitory error // could also be failed. $pheanstalk->release($mailJob->getPheanstalkJob(), Pheanstalk::DEFAULT_PRIORITY, $delay); - return null; } @@ -144,7 +132,6 @@ public function ack(MailJobInterface $mailJob) public function isEmpty() { $stats = $this->getConnection()->getInstance()->statsTube($this->queueName); - return (int) $stats->current_jobs_delayed === 0 && (int) $stats->current_jobs_urgent === 0 && (int) $stats->current_jobs_ready === 0; @@ -157,12 +144,10 @@ public function isEmpty() */ protected function createPayload(MailJobInterface $mailJob) { - return json_encode( - [ + return json_encode([ 'id' => $mailJob->isNewRecord() ? sha1(Random::string(32)) : $mailJob->getId(), 'attempt' => $mailJob->getAttempt(), 'message' => $mailJob->getMessage(), - ] - ); + ]); } } diff --git a/src/Queue/Backend/Beanstalkd/BeanstalkdQueueStoreConnection.php b/src/Queue/Backend/Beanstalkd/BeanstalkdQueueStoreConnection.php index d8659c3..fdb7582 100644 --- a/src/Queue/Backend/Beanstalkd/BeanstalkdQueueStoreConnection.php +++ b/src/Queue/Backend/Beanstalkd/BeanstalkdQueueStoreConnection.php @@ -1,4 +1,5 @@ getConfigurationValue('port', Pheanstalk::DEFAULT_PORT); $connectionTimeout = $this->getConfigurationValue('connectionTimeout'); $connectPersistent = $this->getConfigurationValue('connectPersistent', false); - $connection = new Connection(new SocketFactory($host, $port ?: Pheanstalk::DEFAULT_PORT, $connectionTimeout ?? 0, $connectPersistent ?? SocketFactory::AUTODETECT)); $this->instance = new Pheanstalk($connection); - return $this; } diff --git a/src/Queue/Backend/MailJobInterface.php b/src/Queue/Backend/MailJobInterface.php index 3740915..514d821 100644 --- a/src/Queue/Backend/MailJobInterface.php +++ b/src/Queue/Backend/MailJobInterface.php @@ -1,4 +1,5 @@ state = self::STATE_COMPLETED; - parent::markAsCompleted(); } diff --git a/src/Queue/Backend/Pdo/PdoQueueStoreAdapter.php b/src/Queue/Backend/Pdo/PdoQueueStoreAdapter.php index d7b3038..59abfbe 100644 --- a/src/Queue/Backend/Pdo/PdoQueueStoreAdapter.php +++ b/src/Queue/Backend/Pdo/PdoQueueStoreAdapter.php @@ -1,4 +1,5 @@ getConnection()->connect(); - return $this; } @@ -57,14 +56,10 @@ public function getConnection() */ public function enqueue(MailJobInterface $mailJob) { - $sql = sprintf( - 'INSERT INTO `%s` (`message`, `timeToSend`) VALUES (:message, :timeToSend)', - $this->tableName - ); + $sql = sprintf('INSERT INTO `%s` (`message`, `timeToSend`) VALUES (:message, :timeToSend)', $this->tableName); $query = $this->getConnection()->getInstance()->prepare($sql); $query->bindValue(':message', $mailJob->getMessage()); $query->bindValue(':timeToSend', $mailJob->getTimeToSend()); - return $query->execute(); } @@ -76,33 +71,28 @@ public function enqueue(MailJobInterface $mailJob) public function dequeue() { $this->getConnection()->getInstance()->beginTransaction(); - $mailJob = null; $sqlText = 'SELECT `id`, `message`, `attempt` FROM `%s` WHERE `timeToSend` <= :timeToSend AND `state`=:state ORDER BY id ASC LIMIT 1 FOR UPDATE'; $sql = sprintf($sqlText, $this->tableName); $query = $this->getConnection()->getInstance()->prepare($sql); - $query->bindValue(':state', PdoMailJob::STATE_NEW); $query->bindValue(':timeToSend', date('Y-m-d H:i:s'), time()); $query->execute(); $queryResult = $query->fetch(PDO::FETCH_ASSOC); - if ($queryResult) { - // + // $sqlText = 'UPDATE `%s` SET `state`=:state WHERE `id`=:id'; $sql = sprintf($sqlText, $this->tableName); $query = $this->getConnection()->getInstance()->prepare($sql); $query->bindValue(':state', PdoMailJob::STATE_ACTIVE); $query->bindValue(':id', $queryResult['id'], PDO::PARAM_INT); $query->execute(); - $mailJob = new PdoMailJob($queryResult); } $this->getConnection()->getInstance()->commit(); - return $mailJob; } @@ -128,13 +118,11 @@ public function ack(MailJobInterface $mailJob) $sql = sprintf($sqlText, $this->tableName); $sentTime = $mailJob->isCompleted() ? date('Y-m-d H:i:s', time()) : null; $query = $this->getConnection()->getInstance()->prepare($sql); - $query->bindValue(':id', $mailJob->getId(), PDO::PARAM_INT); $query->bindValue(':attempt', $mailJob->getAttempt(), PDO::PARAM_INT); $query->bindValue(':state', $mailJob->getState()); $query->bindValue(':timeToSend', $mailJob->getTimeToSend()); $query->bindValue(':sentTime', $sentTime); - return $query->execute(); } @@ -143,16 +131,11 @@ public function ack(MailJobInterface $mailJob) */ public function isEmpty() { - $sql = sprintf( - 'SELECT COUNT(`id`) FROM `%s` WHERE `timeToSend` <= :timeToSend AND `state`=:state ORDER BY id ASC LIMIT 1', - $this->tableName - ); + $sql = sprintf('SELECT COUNT(`id`) FROM `%s` WHERE `timeToSend` <= :timeToSend AND `state`=:state ORDER BY id ASC LIMIT 1', $this->tableName); $query = $this->getConnection()->getInstance()->prepare($sql); - $query->bindValue(':state', PdoMailJob::STATE_NEW); $query->bindValue(':timeToSend', date('Y-m-d H:i:s'), time()); $query->execute(); - return intval($query->fetchColumn(0)) === 0; } } diff --git a/src/Queue/Backend/Pdo/PdoQueueStoreConnection.php b/src/Queue/Backend/Pdo/PdoQueueStoreConnection.php index 05acd59..9bc5906 100644 --- a/src/Queue/Backend/Pdo/PdoQueueStoreConnection.php +++ b/src/Queue/Backend/Pdo/PdoQueueStoreConnection.php @@ -1,4 +1,5 @@ configuration['dsn'])) { - $this->configuration['dsn'] = sprintf( - "mysql:host=%s;dbname=%s;port=%s", - $this->configuration['host'] ?? '', - $this->configuration['db'] ?? '', - $this->configuration['port'] ?? 3306 - ); + $this->configuration['dsn'] = sprintf("mysql:host=%s;dbname=%s;port=%s", $this->configuration['host'] ?? '', $this->configuration['db'] ?? '', $this->configuration['port'] ?? 3306); } } @@ -35,14 +31,11 @@ protected function defineConnectionString() public function connect() { $this->disconnect(); - $username = $this->getConfigurationValue('username'); $password = $this->getConfigurationValue('password'); $options = $this->getConfigurationValue('options'); - $this->instance = new PDO($this->getConfigurationValue('dsn'), $username, $password, $options); $this->instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - return $this; } diff --git a/src/Queue/Backend/QueueStoreAdapterInterface.php b/src/Queue/Backend/QueueStoreAdapterInterface.php index f183dc5..d081c34 100644 --- a/src/Queue/Backend/QueueStoreAdapterInterface.php +++ b/src/Queue/Backend/QueueStoreAdapterInterface.php @@ -1,4 +1,5 @@ configuration['port'], $this->configuration['user'], $this->configuration['password'] - ); $this->instance = $this->connection->channel(); diff --git a/src/Queue/Backend/Redis/RedisMailJob.php b/src/Queue/Backend/Redis/RedisMailJob.php index c1ee438..2c1e470 100644 --- a/src/Queue/Backend/Redis/RedisMailJob.php +++ b/src/Queue/Backend/Redis/RedisMailJob.php @@ -1,4 +1,5 @@ getConnection() ->connect(); - return $this; } @@ -64,7 +63,6 @@ public function enqueue(MailJobInterface $mailJob) { $timestamp = $mailJob->getTimeToSend(); $payload = $this->createPayload($mailJob); - return $timestamp !== null && $timestamp > time() ? $this->getConnection()->getInstance()->zadd($this->queueName . ':delayed', $timestamp, $payload) : $this->getConnection()->getInstance()->rpush($this->queueName, $payload); @@ -76,23 +74,17 @@ public function enqueue(MailJobInterface $mailJob) public function dequeue() { $this->migrateExpiredJobs(); - $job = $this->getConnection()->getInstance()->lpop($this->queueName); - if ($job !== null) { $this->getConnection() ->getInstance() ->zadd($this->queueName . ':reserved', time() + $this->expireTime, $job); - $data = json_decode($job, true); - - return new RedisMailJob( - [ + return new RedisMailJob([ 'id' => $data['id'], 'attempt' => $data['attempt'], 'message' => $data['message'], - ] - ); + ]); } return null; @@ -108,7 +100,6 @@ public function ack(MailJobInterface $mailJob) } $this->removeReserved($mailJob); - if (!$mailJob->isCompleted()) { if ($mailJob->getTimeToSend() === null || $mailJob->getTimeToSend() < time()) { $mailJob->setTimeToSend(time() + $this->expireTime); @@ -141,13 +132,11 @@ public function isEmpty() */ protected function createPayload(MailJobInterface $mailJob) { - return json_encode( - [ + return json_encode([ 'id' => $mailJob->isNewRecord() ? sha1(Random::string(32)) : $mailJob->getId(), 'attempt' => $mailJob->getAttempt(), 'message' => $mailJob->getMessage(), - ] - ); + ]); } /** @@ -168,24 +157,21 @@ protected function migrateExpiredJobs() protected function migrateJobs($from, $to) { $options = ['cas' => true, 'watch' => $from, 'retry' => 10]; + $this->getConnection()->getInstance()->transaction($options, function ($transaction) use ($from, $to) { - $this->getConnection()->getInstance()->transaction( - $options, - function ($transaction) use ($from, $to) { $time = time(); - // First we need to get all of jobs that have expired based on the current time + // First we need to get all of jobs that have expired based on the current time // so that we can push them onto the main queue. After we get them we simply // remove them from this "delay" queues. All of this within a transaction. $jobs = $this->getExpiredJobs($transaction, $from, $time); - // If we actually found any jobs, we will remove them from the old queue and we + // If we actually found any jobs, we will remove them from the old queue and we // will insert them onto the new (ready) "queue". This means they will stand // ready to be processed by the queue worker whenever their turn comes up. - if (count($jobs) > 0) { - $this->removeExpiredJobs($transaction, $from, $time); - $this->pushExpiredJobsOntoNewQueue($transaction, $to, $jobs); - } + if (count($jobs) > 0) { + $this->removeExpiredJobs($transaction, $from, $time); + $this->pushExpiredJobsOntoNewQueue($transaction, $to, $jobs); } - ); + }); } /** diff --git a/src/Queue/Backend/Redis/RedisQueueStoreConnection.php b/src/Queue/Backend/Redis/RedisQueueStoreConnection.php index 96e76b4..7905e98 100644 --- a/src/Queue/Backend/Redis/RedisQueueStoreConnection.php +++ b/src/Queue/Backend/Redis/RedisQueueStoreConnection.php @@ -1,4 +1,5 @@ disconnect(); $this->instance = new Client($this->configuration); - return $this; } diff --git a/src/Queue/Backend/Sqs/SqsMailJob.php b/src/Queue/Backend/Sqs/SqsMailJob.php index cb2812e..3756523 100644 --- a/src/Queue/Backend/Sqs/SqsMailJob.php +++ b/src/Queue/Backend/Sqs/SqsMailJob.php @@ -1,4 +1,5 @@ getConnection()->connect(); - - // create new queue or get existing one +// create new queue or get existing one $queue = $this->getConnection()->getInstance()->createQueue([ 'QueueName' => $this->queueName, ]); $this->queueUrl = $queue['QueueUrl']; - return $this; } @@ -71,7 +69,6 @@ public function enqueue(MailJobInterface $mailJob) 'Attempt' => $mailJob->getAttempt(), ]); $messageId = $result['MessageId']; - return $messageId !== null && is_string($messageId); } @@ -85,13 +82,11 @@ public function dequeue() $result = $this->getConnection()->getInstance()->receiveMessage([ 'QueueUrl' => $this->queueUrl, ]); - if (empty($result['Messages'])) { return null; } $result = array_shift($result['Messages']); - return new SqsMailJob([ 'id' => $result['MessageId'], 'receiptHandle' => $result['ReceiptHandle'], @@ -116,7 +111,6 @@ public function ack(MailJobInterface $mailJob) 'QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $mailJob->getReceiptHandle(), ]); - return true; } elseif ($mailJob->getVisibilityTimeout() !== null) { $this->getConnection()->getInstance()->changeMessageVisibility([ @@ -124,7 +118,6 @@ public function ack(MailJobInterface $mailJob) 'ReceiptHandle' => $mailJob->getReceiptHandle(), 'VisibilityTimeout' => $mailJob->getVisibilityTimeout(), ]); - return true; } @@ -140,7 +133,6 @@ public function isEmpty(): bool 'QueueUrl' => $this->queueUrl, 'AttributeNames' => ['ApproximateNumberOfMessages'], ]); - return $response['Attributes']['ApproximateNumberOfMessages'] === 0; } } diff --git a/src/Queue/Backend/Sqs/SqsQueueStoreConnection.php b/src/Queue/Backend/Sqs/SqsQueueStoreConnection.php index d224d95..eb67911 100644 --- a/src/Queue/Backend/Sqs/SqsQueueStoreConnection.php +++ b/src/Queue/Backend/Sqs/SqsQueueStoreConnection.php @@ -1,4 +1,5 @@ getConfigurationValue('key'); $secret = $this->getConfigurationValue('secret'); $region = $this->getConfigurationValue('region'); - $this->instance = new SqsClient([ 'key' => $key, 'secret' => $secret, 'region' => $region, ]); - return $this; } diff --git a/src/Queue/Cli/MailMessageWorker.php b/src/Queue/Cli/MailMessageWorker.php index a2c375a..7560815 100644 --- a/src/Queue/Cli/MailMessageWorker.php +++ b/src/Queue/Cli/MailMessageWorker.php @@ -1,4 +1,5 @@ mailer->send($this->mailMessage); if (is_null($sentMessage)) { diff --git a/src/Security/Cypher.php b/src/Security/Cypher.php index b6fb659..cc8ce28 100644 --- a/src/Security/Cypher.php +++ b/src/Security/Cypher.php @@ -1,4 +1,5 @@ key = $key; $this->iv = $iv; - // initialize cypher with strongest mode and with AES. Is an anti-pattern and should be passed through the +// initialize cypher with strongest mode and with AES. Is an anti-pattern and should be passed through the // constructor as an argument, but this way we ensure the library does have the strongest strategy by default. $this->strategy = new AES('cbc'); - $this->strategy->setKeyLength(256); } @@ -39,7 +38,6 @@ public function encodeMailMessage(MailMessage $mailMessage) $jsonEncodedMailMessage = json_encode($mailMessage, JSON_NUMERIC_CHECK); $this->strategy->setKey($this->key); $this->strategy->setIV($this->iv); - return base64_encode($this->strategy->encrypt($jsonEncodedMailMessage)); } @@ -51,7 +49,6 @@ public function decodeMailMessage($encodedMailMessage) $this->strategy->setKey($this->key); $decryptedMailMessage = $this->strategy->decrypt(base64_decode($encodedMailMessage, true)); $jsonDecodedMailMessageAttributes = json_decode($decryptedMailMessage, true); - return new MailMessage($jsonDecodedMailMessageAttributes); } } diff --git a/src/Security/CypherInterface.php b/src/Security/CypherInterface.php index 1a13b97..7df8837 100644 --- a/src/Security/CypherInterface.php +++ b/src/Security/CypherInterface.php @@ -1,4 +1,5 @@ dsn = $dsn; diff --git a/src/Transport/MailTransportFactory.php b/src/Transport/MailTransportFactory.php index 97960b0..7ee5e5a 100644 --- a/src/Transport/MailTransportFactory.php +++ b/src/Transport/MailTransportFactory.php @@ -1,4 +1,5 @@ dsn = $dsn; @@ -29,7 +28,6 @@ public function getInstance(): \Symfony\Component\Mailer\Transport\SendmailTrans { if ($this->instance === null) { $sendMailFactory = new \Symfony\Component\Mailer\Transport\SendmailTransportFactory(); - $this->instance = $sendMailFactory->create(Dsn::fromString($this->dsn)); } diff --git a/src/Transport/SendMailTransportFactory.php b/src/Transport/SendMailTransportFactory.php index aa1d147..8784c7d 100644 --- a/src/Transport/SendMailTransportFactory.php +++ b/src/Transport/SendMailTransportFactory.php @@ -1,4 +1,5 @@ instance === null) { $user = $this->options['username'] ?? null; $password = $this->options['password'] ?? null; - - $this->instance = (new EsmtpTransportFactory())->create( - new Dsn('smtp', $this->host, $user, $password, $this->port, $this->options) - ); + $this->instance = (new EsmtpTransportFactory())->create(new Dsn('smtp', $this->host, $user, $password, $this->port, $this->options)); } return $this->instance; diff --git a/src/Transport/SmtpTransportFactory.php b/src/Transport/SmtpTransportFactory.php index 1569a95..7fd0ddb 100644 --- a/src/Transport/SmtpTransportFactory.php +++ b/src/Transport/SmtpTransportFactory.php @@ -1,4 +1,5 @@ options, 'host'); $port = ArrayHelper::remove($this->options, 'port'); $options = ArrayHelper::getValue($this->options, 'options', []); - return new SmtpTransport($host, $port, $options); } } diff --git a/src/Transport/TransportFactory.php b/src/Transport/TransportFactory.php index e602f83..ec5b776 100644 --- a/src/Transport/TransportFactory.php +++ b/src/Transport/TransportFactory.php @@ -1,8 +1,10 @@