Callback::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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