Passed
Pull Request — master (#78)
by Rafael
06:25 queued 01:04
created

QueueProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 31
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 26 1
1
<?php
2
3
namespace Gewaer\Providers;
4
5
use Phalcon\Di\ServiceProviderInterface;
6
use Phalcon\DiInterface;
7
use Phalcon\Queue\Beanstalk\Extended as Beanstalk;
8
use function Gewaer\Core\envValue;
9
10
class QueueProvider implements ServiceProviderInterface
11
{
12
    /**
13
     * @param DiInterface $container
14
     */
15 72
    public function register(DiInterface $container)
16
    {
17
        // $container->setShared(
18
        //     'queue',
19
        //     function () {
20
        //         //Connect to the queue
21
        //         $queue = new \PhpAmqpLib\Connection\AMQPStreamConnection(
22
        //             envValue('RABBITMQ_HOST'),
23
        //             envValue('RABBITMQ_PORT'),
24
        //             envValue('RABBITMQ_DEFAULT_USER'),
25
        //             envValue('RABBITMQ_DEFAULT_PASS')
26
        //         );
27
28
        //         return $queue;
29
        //     }
30
        // );
31
32 72
        $container->setShared(
33 72
            'queue',
34
            function () {
35
                //Connect to the queue
36 3
                $queue = new Beanstalk([
37 3
                    'host' => envValue('DATA_API_BEANSTALK_HOST', '127.0.0.1'),
38 3
                    'prefix' => envValue('DATA_API_BEANSTALK_PORT', 11300),
39
                ]);
40 3
                return $queue;
41 72
            }
42
        );
43 72
    }
44
}
45