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

Webhook::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Slides\Connector\Auth\Webhooks;
4
5
use Illuminate\Support\Facades\Validator;
6
7
/**
8
 * Class Webhook
9
 *
10
 * @package Slides\Connector\Auth\Webhooks
11
 */
12
abstract class Webhook implements \Slides\Connector\Auth\Contracts\Webhook
13
{
14
    /**
15
     * The request payload.
16
     *
17
     * @var array
18
     */
19
    protected $payload;
20
21
    /**
22
     * Validator instance.
23
     *
24
     * @var \Illuminate\Validation\Validator
25
     */
26
    protected $validator;
27
28
    /**
29
     * The payload validation rules.
30
     *
31
     * @return array
32
     */
33
    protected abstract function rules();
34
35
    /**
36
     * Validate a payload.
37
     *
38
     * @param array $payload
39
     *
40
     * @return bool
41
     */
42
    public function validate(array $payload): bool
43
    {
44
        $this->validator = Validator::make($payload, $this->rules());
45
46
        return $this->validator->passes();
47 1
    }
48
49 1
    /**
50 1
     * Get validator instance.
51 1
     *
52
     * @return \Illuminate\Validation\Validator
53
     */
54
    public function getValidator(): \Illuminate\Validation\Validator
55
    {
56
        return $this->validator;
57
    }
58
}