Completed
Push — master ( cec13a...c9e853 )
by Adrian Florin
21s queued 15s
created

EntityArgumentsInterpreter::interpretProperties()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
namespace NeedleProject\LaravelRabbitMq\Interpreter;
4
5
use PhpAmqpLib\Wire\AMQPTable;
6
7
class EntityArgumentsInterpreter
8
{
9
    /**
10
     * For a accurate usage, please reffer to https://www.rabbitmq.com/queues.html#optional-arguments
11
     *
12
     * @param AMQPTable|array $entityArguments
13
     * @return AMQPTable
14
     */
15
    public static function interpretArguments($entityArguments): AMQPTable
16
    {
17
        if ($entityArguments instanceof AMQPTable) {
18
            return $entityArguments;
19
        }
20
        return new AMQPTable($entityArguments);
21
    }
22
23
    public static function interpretProperties(array $attributes, array $properties): array
24
    {
25
        if (isset($attributes['durable']) && $attributes['durable'] === true) {
26
            $properties['delivery_mode'] = 2;
27
        }
28
        return $properties;
29
    }
30
}
31