Skip to content

Commit

Permalink
fix cs errors
Browse files Browse the repository at this point in the history
  • Loading branch information
2amjsouza committed Jan 20, 2024
1 parent f887b33 commit 44e024f
Show file tree
Hide file tree
Showing 45 changed files with 152 additions and 221 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ index
.composer.lock
.phpunit.cache
composer.lock
PHP_CodeSniffer
2 changes: 1 addition & 1 deletion src/Builder/Buildable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
5 changes: 3 additions & 2 deletions src/Builder/MailJobBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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();
}
}
}
5 changes: 3 additions & 2 deletions src/Builder/QueueBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -66,7 +66,8 @@ protected static function getBrokerAdapter($messageBroker)
return new RabbitMqQueueStoreAdapter(
new RabbitMqQueueConnection($connectionValues)
);
default: throw new UndefinedMessageBrokerException();
default:
throw new UndefinedMessageBrokerException();
}
}
}
9 changes: 4 additions & 5 deletions src/Event/Event.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Event;

use Da\Mailer\Exception\InvalidCallbackArgumentException;
Expand All @@ -9,16 +10,15 @@ class Event
* @var object the class firing the event.
*/
public $owner;
/**
/**
* @var array the collected arguments passed to the event
*/
private $data;
/**
/**
* @var callable
*/
private $handler;

/**
/**
* Callback constructor.
*
* @param callable $handler
Expand All @@ -37,7 +37,6 @@ public function __construct($handler)
public function __invoke()
{
$this->data = func_get_args();

return call_user_func($this->handler, $this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Event/EventHandlerTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Event;

trait EventHandlerTrait
Expand All @@ -7,8 +8,7 @@ trait EventHandlerTrait
* @var array stack of events attached to the manager
*/
protected $events = [];

/**
/**
* Adds an Event instance to the stack based on the name.
*
* @param string $name the identifier of the stack
Expand Down
1 change: 1 addition & 0 deletions src/Exception/InvalidCallException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Exception;

use BadMethodCallException;
Expand Down
1 change: 1 addition & 0 deletions src/Exception/InvalidCallbackArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Exception;

use InvalidArgumentException;
Expand Down
1 change: 1 addition & 0 deletions src/Exception/InvalidTransportTypeArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Exception;

use InvalidArgumentException;
Expand Down
1 change: 0 additions & 1 deletion src/Exception/UndefinedMessageBrokerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

class UndefinedMessageBrokerException extends Exception
{

}
1 change: 1 addition & 0 deletions src/Exception/UnknownPropertyException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Exception;

use Exception;
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/ArrayHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Helper;

use Closure;
Expand Down Expand Up @@ -96,7 +97,6 @@ public static function remove(&$array, $key, $default = null)
if (is_array($array) && (isset($array[$key]) || array_key_exists($key, $array))) {
$value = $array[$key];
unset($array[$key]);

return $value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Helper/PhpViewFileHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Helper;

final class PhpViewFileHelper
Expand All @@ -20,7 +21,6 @@ public static function render($file, array $params = [])
ob_implicit_flush(false);
extract($params, EXTR_OVERWRITE);
require $file;

return ob_get_clean();
}
}
1 change: 1 addition & 0 deletions src/Helper/RecipientsHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Helper;

class RecipientsHelper
Expand Down
9 changes: 3 additions & 6 deletions src/Mailer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer;

use Da\Mailer\Builder\MessageBuilder;
Expand All @@ -14,12 +15,11 @@ class Mailer
* @var TransportInterface|null the transport used to send emails.
*/
private $transport = null;
/**
/**
* @var bool
*/
private $logging = true;

/**
/**
* Constructor.
*
* @param TransportInterface $transport the transport to use for sending emails.
Expand Down Expand Up @@ -103,7 +103,6 @@ public function setTransport(TransportInterface $transport)
public function send(MailMessage $message, array $views = [], array $data = []): ?SentMessage
{
$message = MessageBuilder::make($message);

return $this->getTransportInstance()->send($message);
}

Expand All @@ -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());
}
}
1 change: 1 addition & 0 deletions src/Model/AbstractMailObject.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Model;

use Da\Mailer\Exception\InvalidCallException;
Expand Down
10 changes: 5 additions & 5 deletions src/Model/MailJob.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Model;

use Da\Mailer\Queue\Backend\MailJobInterface;
Expand All @@ -9,22 +10,21 @@ class MailJob extends AbstractMailObject implements MailJobInterface
* @var mixed
*/
private $id;
/**
/**
* @var MailMessage|string
*/
private $message;
/**
/**
* @var int number of attempts. Every time a mail fails to be sent, the number of attempts could be incremented.
*
* @see `incrementAttempt()`
*/
private $attempt = 0;
/**
/**
* @var bool whether the job has been completed
*/
private $completed = false;

/**
/**
* {@inheritdoc}
*/
public function __construct(array $config = [])
Expand Down
28 changes: 13 additions & 15 deletions src/Model/MailMessage.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Model;

use Da\Mailer\Builder\MailJobBuilder;
Expand Down Expand Up @@ -33,53 +34,52 @@ class MailMessage extends AbstractMailObject implements JsonSerializable
* ```
*/
public $transportOptions = [];
/**
/**
* @var string the transport type. It could be TransportInterface::TYPE_SMTP, TransportInterface::TYPE_MAIL, o
* TransportInterface::TYPE_SEND_MAIL.
*/
public $transportType;
/**
/**
* @var string the mail server address.
*/
public $host;
/**
/**
* @var int the mail server port.
*/
public $port;
/**
/**
* @var array|string the from address/es
*/
public $from;
/**
/**
* @var array|string the to address/es
*/
public $to;
/**
/**
* @var array|string the cc address/es
*/
public $cc;
/**
/**
* @var array|string the bcc address/es
*/
public $bcc;
/**
/**
* @var string the subject of the mail message
*/
public $subject;
/**
/**
* @var string the body html of the mail message
*/
public $bodyHtml;
/**
/**
* @var string the body
*/
public $bodyText;
/**
/**
* @var array|null the file paths to attach to the Swift_Message instance if `asSwiftMessage()` is called
*/
protected $attachments;

/**
/**
* {@inheritdoc}
*/
public function __construct(array $config = [])
Expand Down Expand Up @@ -118,7 +118,6 @@ public function jsonSerialize()
public function enqueue()
{
$job = MailJobBuilder::make(['message' => json_encode($this)]);

QueueBuilder::make()->enqueue($job);
}

Expand All @@ -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;
}

Expand Down
9 changes: 4 additions & 5 deletions src/Queue/Backend/AbstractQueueStoreConnection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Queue\Backend;

use Da\Mailer\Helper\ArrayHelper;
Expand All @@ -9,12 +10,11 @@ abstract class AbstractQueueStoreConnection
* @var mixed the internal connection instance (ie. PDO)
*/
protected $instance;
/**
/**
* @var array
*/
protected $configuration = [];

/**
/**
* AbstractQueueStoreConnection constructor.
*
* @param array $configuration
Expand Down Expand Up @@ -47,8 +47,7 @@ public function disconnect()
* @return AbstractQueueStoreConnection
*/
abstract public function connect();

/**
/**
* @return mixed
*/
abstract public function getInstance();
Expand Down
6 changes: 3 additions & 3 deletions src/Queue/Backend/Beanstalkd/BeanstalkdMailJob.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Da\Mailer\Queue\Backend\Beanstalkd;

use Da\Mailer\Model\MailJob;
Expand All @@ -10,12 +11,11 @@ class BeanstalkdMailJob extends MailJob
* @var int the unix timestamp the job should be processed
*/
private $timeToSend;
/**
/**
* @var PheanstalkJob
*/
private $pheanstalkJob;

/**
/**
* @return int the timestamp
*/
public function getTimeToSend()
Expand Down
Loading

0 comments on commit 44e024f

Please sign in to comment.