1 | <?php |
||||
2 | |||||
3 | namespace Da\Mailer\Builder; |
||||
4 | |||||
5 | use Da\Mailer\Enum\MessageBrokerEnum; |
||||
6 | use Da\Mailer\Exception\UndefinedMessageBrokerException; |
||||
7 | use Da\Mailer\Model\MailJob; |
||||
8 | use Da\Mailer\Queue\Backend\Beanstalkd\BeanstalkdMailJob; |
||||
9 | use Da\Mailer\Queue\Backend\Pdo\PdoMailJob; |
||||
10 | use Da\Mailer\Queue\Backend\RabbitMq\RabbitMqJob; |
||||
11 | use Da\Mailer\Queue\Backend\Redis\RedisMailJob; |
||||
12 | use Da\Mailer\Queue\Backend\Sqs\SqsMailJob; |
||||
13 | |||||
14 | class MailJobBuilder extends Buildable |
||||
15 | { |
||||
16 | /** |
||||
17 | * @param array|null $jobAttributes |
||||
18 | * @param string|null $broker |
||||
19 | * @return MailJob |
||||
20 | * @throws UndefinedMessageBrokerException |
||||
21 | */ |
||||
22 | public static function make($jobAttributes = null, ?string $broker = null): MailJob |
||||
23 | { |
||||
24 | $config = self::getConfig(); |
||||
25 | $messageBroker = $broker ?? $config['config']['message_broker']; |
||||
26 | |||||
27 | switch ($messageBroker) { |
||||
28 | case MessageBrokerEnum::BROKER_REDIS: |
||||
29 | return new RedisMailJob($jobAttributes); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() The expression
return new Da\Mailer\Que...MailJob($jobAttributes) returns the type Da\Mailer\Queue\Backend\Redis\RedisMailJob which is incompatible with the return type mandated by Da\Mailer\Builder\Buildable::make() of void .
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
![]() |
|||||
30 | case MessageBrokerEnum::BROKER_SQS: |
||||
31 | return new SqsMailJob($jobAttributes); |
||||
0 ignored issues
–
show
The expression
return new Da\Mailer\Que...MailJob($jobAttributes) returns the type Da\Mailer\Queue\Backend\Sqs\SqsMailJob which is incompatible with the return type mandated by Da\Mailer\Builder\Buildable::make() of void .
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
![]() It seems like
$jobAttributes can also be of type null ; however, parameter $config of Da\Mailer\Queue\Backend\...sMailJob::__construct() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
32 | case MessageBrokerEnum::BROKER_BEANSTALKD: |
||||
33 | return new BeanstalkdMailJob($jobAttributes); |
||||
0 ignored issues
–
show
The expression
return new Da\Mailer\Que...MailJob($jobAttributes) returns the type Da\Mailer\Queue\Backend\...talkd\BeanstalkdMailJob which is incompatible with the return type mandated by Da\Mailer\Builder\Buildable::make() of void .
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
![]() It seems like
$jobAttributes can also be of type null ; however, parameter $config of Da\Mailer\Queue\Backend\...dMailJob::__construct() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
34 | case MessageBrokerEnum::BROKER_PDO: |
||||
35 | return new PdoMailJob($jobAttributes); |
||||
0 ignored issues
–
show
The expression
return new Da\Mailer\Que...MailJob($jobAttributes) returns the type Da\Mailer\Queue\Backend\Pdo\PdoMailJob which is incompatible with the return type mandated by Da\Mailer\Builder\Buildable::make() of void .
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
![]() It seems like
$jobAttributes can also be of type null ; however, parameter $config of Da\Mailer\Queue\Backend\...oMailJob::__construct() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
36 | case MessageBrokerEnum::BROKER_RABBITMQ: |
||||
37 | return new RabbitMqJob($jobAttributes); |
||||
0 ignored issues
–
show
It seems like
$jobAttributes can also be of type null ; however, parameter $config of Da\Mailer\Queue\Backend\...bitMqJob::__construct() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The expression
return new Da\Mailer\Que...itMqJob($jobAttributes) returns the type Da\Mailer\Queue\Backend\RabbitMq\RabbitMqJob which is incompatible with the return type mandated by Da\Mailer\Builder\Buildable::make() of void .
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
![]() |
|||||
38 | default: |
||||
39 | throw new UndefinedMessageBrokerException(); |
||||
40 | } |
||||
41 | } |
||||
42 | } |
||||
43 |