Test Setup Failed
Push — master ( e9a1d5...421647 )
by
unknown
03:08
created

Driver::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Drivers;
6
7
use Illuminate\Support\Collection;
8
use FondBot\Contracts\Driver as DriverContract;
9
10
abstract class Driver implements DriverContract
11
{
12
    /** @var Collection */
13
    protected $parameters;
14
15
    /**
16
     * Get driver short name.
17
     *
18
     * This name is used as an alias for configuration.
19
     *
20
     * @return string
21
     */
22
    public function getShortName(): string
23
    {
24
        $shortName = explode('\\', get_class($this));
25
26 3
        return collect($shortName)->last();
27
    }
28 3
29 3
    /**
30
     * Initialize driver.
31
     *
32
     * @param array $parameters
33
     *
34
     * @return Driver|DriverContract|static
35
     */
36
    public function initialize(array $parameters): DriverContract
37
    {
38 1
        foreach ($this->getDefaultParameters() as $key => $value) {
39
            $value = array_get($parameters, $key, $value);
40 1
41
            array_set($parameters, $key, $value);
42 1
        }
43
44
        $this->parameters = collect($parameters);
45
46
        return $this;
47
    }
48
49
    /**
50
     * Get driver parameters.
51
     *
52
     * @return Collection
53 2
     */
54
    public function getParameters(): Collection
55 2
    {
56
        return $this->parameters;
57 2
    }
58
}
59