Passed
Push — master ( c34bce...f6db7f )
by Artem
01:28
created

AssessUsersWebhook   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 41
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 5 1
A handle() 0 4 1
A __construct() 0 3 1
1
<?php
2
3
namespace Slides\Connector\Auth\Webhooks;
4
5
use Slides\Connector\Auth\Services\Assessment\AssessmentService;
6
7
/**
8
 * Class AssessUsersWebhook
9
 *
10
 * @package Slides\Connector\Auth\Webhooks
11
 */
12
class AssessUsersWebhook extends Webhook
13
{
14
    /**
15
     * @var AssessmentService
16
     */
17
    protected $assessmentService;
18
19
    /**
20
     * AssessUsersWebhook constructor.
21
     *
22
     * @param AssessmentService $assessmentService
23
     */
24
    public function __construct(AssessmentService $assessmentService)
25
    {
26
        $this->assessmentService = $assessmentService;
27
    }
28
29
    /**
30
     * The payload validation rules.
31
     *
32
     * @return array
33
     */
34
    protected function rules(): array
35
    {
36
        return [
37
            'keys' => 'required|array',
38
            'keys.*' => 'int'
39
        ];
40
    }
41
    
42
    /**
43
     * Handle the incoming request.
44
     *
45
     * @param array $payload
46
     *
47
     * @return array
48
     */
49
    public function handle(array $payload)
50
    {
51
        return $this->assessmentService->differentiateUsers(
52
            array_get($payload, 'keys', [])
53
        );
54
    }
55
}