SyncProvider::receive()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 1
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 1
eloc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * Copyright 2014 Underground Elephant
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 *
18
 * @package     qpush-bundle
19
 * @copyright   Underground Elephant 2014
20
 * @license     Apache License, Version 2.0
21
 */
22
23
namespace Uecode\Bundle\QPushBundle\Provider;
24
25
26
use Doctrine\Common\Cache\Cache;
27
use Monolog\Logger;
28
use Uecode\Bundle\QPushBundle\Event\Events;
29
use Uecode\Bundle\QPushBundle\Event\MessageEvent;
30
use Uecode\Bundle\QPushBundle\Message\Message;
31
32
class SyncProvider extends AbstractProvider
33
{
34
    /**
35
     * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
36
     */
37
    protected $dispatcher;
38
39 6 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
        $name,
41
        array $options,
42
        $client,
43
        Cache $cache,
44
        Logger $logger
45
    ) {
46 6
        $this->name = $name;
47 6
        $this->options = $options;
48 6
        $this->dispatcher = $client;
49 6
        $this->cache = $cache;
50 6
        $this->logger = $logger;
51 6
    }
52
53 1
    public function getProvider()
54
    {
55 1
        return 'Sync';
56
    }
57
58 1
    public function publish(array $message, array $options = [])
59
    {
60 1
        $message = new Message(time(), $message, []);
61
62 1
        $this->dispatcher->dispatch(
63 1
            Events::Message($this->name),
64 1
            new MessageEvent($this->name, $message)
65
        );
66
67 1
        $context = ['MessageId' => $message->getId()];
68 1
        $this->log(200, 'Message received and dispatched on Sync Queue', $context);
69 1
    }
70
71
    public function create() {}
72
73
    public function destroy() {}
74
75
    public function delete($id) {}
76
77
    public function receive(array $options = []) {}
78
}
79