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

Webhook   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 45
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 5 1
A getValidator() 0 3 1
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 1
    public function validate(array $payload): bool
43
    {
44 1
        $this->validator = Validator::make($payload, $this->rules());
45
46 1
        return $this->validator->passes();
47
    }
48
49
    /**
50
     * Get validator instance.
51
     *
52
     * @return \Illuminate\Validation\Validator
53
     */
54
    public function getValidator(): \Illuminate\Validation\Validator
55
    {
56
        return $this->validator;
57
    }
58
}