Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code style #21

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
62 changes: 0 additions & 62 deletions .php_cs

This file was deleted.

37 changes: 0 additions & 37 deletions .scrutinizer.yml

This file was deleted.

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
Loading