Completed
Push — master ( 57dab7...a3bee9 )
by Tomáš
05:06
created

AbstractQueue::isNoWait()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace Portiny\RabbitMQ\Queue;
4
5
use Bunny\Channel;
6
use Bunny\Exception\BunnyException;
7
use Bunny\Protocol\MethodQueueBindOkFrame;
8
use Bunny\Protocol\MethodQueueDeclareOkFrame;
9
10
abstract class AbstractQueue
11
{
12
	final public function declare(Channel $channel): void
13
	{
14
		$frame = $channel->queueDeclare(
15
			$this->getName(),
16
			$this->isPassive(),
17
			$this->isDurable(),
18
			$this->isExclusive(),
19
			$this->isAutoDelete(),
20
			FALSE,
21
			$this->getArguments()
22
		);
23
		if (! $frame instanceof MethodQueueDeclareOkFrame) {
0 ignored issues
show
Bug introduced by
The class Bunny\Protocol\MethodQueueDeclareOkFrame does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
24
			throw new BunnyException(sprintf('Could not declare queue "%s".', $this->getName()));
25
		}
26
27
		foreach ($this->getBindings() as $queueBind) {
28
			$frame = $channel->queueBind(
29
				$this->getName(),
30
				$queueBind->getExchange(),
31
				$queueBind->getRoutingKey(),
32
				FALSE,
33
				$queueBind->getArguments()
34
			);
35
			if (! $frame instanceof MethodQueueBindOkFrame) {
0 ignored issues
show
Bug introduced by
The class Bunny\Protocol\MethodQueueBindOkFrame does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
36
				throw new BunnyException(
37
					sprintf(
38
						'Could not bind queue "%s" to "%s" with routing key "%s".',
39
						$this->getName(),
40
						$queueBind->getExchange(),
41
						$queueBind->getRoutingKey()
42
					)
43
				);
44
			}
45
		}
46
	}
47
48
	abstract protected function getName(): string;
49
50
	protected function isPassive(): bool
51
	{
52
		return false;
53
	}
54
55
	protected function isDurable(): bool
56
	{
57
		return false;
58
	}
59
60
	protected function isExclusive(): bool
61
	{
62
		return false;
63
	}
64
65
	protected function isAutoDelete(): bool
66
	{
67
		return false;
68
	}
69
70
	protected function isNoWait(): bool
71
	{
72
		return false;
73
	}
74
75
	protected function getArguments(): array
76
	{
77
		return [];
78
	}
79
80
	/**
81
	 * @return QueueBind[]
82
	 */
83
	protected function getBindings(): array
84
	{
85
		return [];
86
	}
87
}
88