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

EntityArgumentsInterpreter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 22
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A interpretArguments() 0 6 2
A interpretProperties() 0 6 3
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