Completed
Push — master ( 817c3d...f287a4 )
by Vladimir
03:07
created

Driver::hasRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Drivers;
6
7
use FondBot\Helpers\Arr;
8
use FondBot\Contracts\Drivers\Driver as DriverContract;
9
10
abstract class Driver implements DriverContract
11
{
12
    /** @var array */
13
    private $request = [];
14
15
    /** @var array */
16
    private $headers = [];
17
18
    /** @var array */
19
    private $parameters;
20
21
    /**
22
     * Set driver data.
23
     *
24
     * @param array $parameters
25
     * @param array $request
26
     * @param array $headers
27
     */
28 1
    public function fill(array $parameters, array $request = [], array $headers = []): void
29
    {
30 1
        $this->parameters = $parameters;
31 1
        $this->request = $request;
32 1
        $this->headers = $headers;
33 1
    }
34
35
    /**
36
     * Get request value.
37
     *
38
     * @param string|null $key
39
     *
40
     * @return mixed
41
     */
42
    public function getRequest(string $key = null)
43
    {
44
        return Arr::get($this->request, $key);
45
    }
46
47
    /**
48
     * If request has key.
49
     *
50
     * @param string $key
51
     *
52
     * @return bool
53
     */
54
    public function hasRequest(string $key): bool
55
    {
56
        return Arr::has($this->request, [$key]);
57
    }
58
59
    /**
60
     * Get all headers.
61
     *
62
     * @return array
63
     */
64
    public function getHeaders(): array
65
    {
66
        return $this->headers;
67
    }
68
69
    /**
70
     * Get header.
71
     *
72
     * @param string $name
73
     *
74
     * @return mixed
75
     */
76
    public function getHeader(string $name)
77
    {
78
        return Arr::get($this->headers, $name);
79
    }
80
81
    /**
82
     * Get parameter value.
83
     *
84
     * @param string $name
85
     *
86
     * @return mixed
87
     */
88
    public function getParameter(string $name)
89
    {
90
        return Arr::get($this->parameters, $name);
91
    }
92
}
93