Callback   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 36
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A generate() 0 3 1
1
<?php
2
3
namespace ShiftOneLabs\LaravelSqsFifoQueue\Queue\Deduplicators;
4
5
use Closure;
6
use ShiftOneLabs\LaravelSqsFifoQueue\Contracts\Queue\Deduplicator;
7
8
class Callback implements Deduplicator
9
{
10
    /**
11
     * The user defined callback function to generate the deduplication id.
12
     *
13
     * @var \Closure
14
     */
15
    protected $callback;
16
17
    /**
18
     * Create a new deduplicator instance.
19
     *
20
     * @param  \Closure  $callback
21
     *
22
     * @return void
23
     */
24 10
    public function __construct(Closure $callback)
25
    {
26 10
        $this->callback = $callback;
27
    }
28
29
    /**
30
     * Generate a deduplication id using the defined callback function.
31
     *
32
     * This deduplicator can be used to allow a developer to quickly generate
33
     * a custom deduplicator using a Closure, without having to implement
34
     * a completely new deduplicator object.
35
     *
36
     * @param  string  $payload
37
     * @param  string  $queue
38
     *
39
     * @return string
40
     */
41 10
    public function generate($payload, $queue)
42
    {
43 10
        return call_user_func($this->callback, $payload, $queue);
44
    }
45
}
46