Completed
Pull Request — master (#3)
by Artem
15:49
created

AssessUsersWebhook::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}