InitializeMessageExchange20190311143000   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 12 1
A getDescription() 0 5 2
A isReversible() 0 3 1
A down() 0 4 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the ngutech/lnd-adapter project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace NGUtech\Lnd\Migration\RabbitMq;
10
11
use Daikon\RabbitMq3\Migration\RabbitMq3Migration;
12
use PhpAmqpLib\Exchange\AMQPExchangeType;
13
14
final class InitializeMessageExchange20190311143000 extends RabbitMq3Migration
15
{
16
    public function getDescription(string $direction = self::MIGRATE_UP): string
17
    {
18
        return $direction === self::MIGRATE_UP
19
            ? 'Create a RabbitMQ message exchange for the LND-Adapter context.'
20
            : 'Delete the RabbitMQ message message exchange for the LND-Adapter context.';
21
    }
22
23
    public function isReversible(): bool
24
    {
25
        return true;
26
    }
27
28
    protected function up(): void
29
    {
30
        $this->createMigrationList('lnd.adapter.migration_list');
31
        $this->declareExchange(
32
            'lnd.adapter.exchange',
33
            'x-delayed-message',
34
            false,
35
            true,
36
            false,
37
            false,
38
            false,
39
            ['x-delayed-type' => AMQPExchangeType::TOPIC]
40
        );
41
    }
42
43
    protected function down(): void
44
    {
45
        $this->deleteExchange('lnd.adapter.exchange');
46
        $this->deleteExchange('lnd.adapter.migration_list');
47
    }
48
}
49