Passed
Push — master ( 30520d...33f18a )
by Vladimir
03:04
created

Driver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 4
eloc 9
dl 0
loc 52
rs 10
c 0
b 0
f 0
ccs 6
cts 8
cp 0.75

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getClient() 0 3 1
A getTemplateCompiler() 0 3 1
A initialize() 0 9 1
A getShortName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Channels;
6
7
use Illuminate\Support\Collection;
8
use FondBot\Drivers\TemplateCompiler;
9
use FondBot\Contracts\Channels\Driver as DriverContract;
10
11
abstract class Driver implements DriverContract
12
{
13
    protected $client;
14
15
    /**
16
     * Get driver short name.
17
     *
18
     * This name is used as an alias for configuration.
19
     *
20 1
     * @return string
21
     */
22 1
    public function getShortName(): string
23
    {
24
        return class_basename($this);
25
    }
26
27
    /**
28
     * Initialize driver.
29
     *
30
     * @param Collection $parameters
31
     *
32 2
     * @return Driver|DriverContract|static
33
     */
34
    public function initialize(Collection $parameters): DriverContract
35 2
    {
36 2
        $parameters->each(function ($value, $key) {
37
            $this->$key = $value;
38 2
        });
39
40
        $this->client = $this->createClient();
41
42
        return $this;
43
    }
44
45
    /**
46
     * Get API client.
47
     *
48
     * @return mixed
49
     */
50
    public function getClient()
51
    {
52
        return $this->client;
53
    }
54
55
    /**
56
     * Get template compiler instance.
57
     *
58
     * @return TemplateCompiler|null
59
     */
60
    public function getTemplateCompiler(): ?TemplateCompiler
61
    {
62
        return null;
63
    }
64
}
65