Completed
Push — master ( 59b9fb...b4679f )
by Vladimir
02:55
created

TemplateCompiler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 10
wmc 2
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
compileKeyboard() 0 1 ?
compilePayloadButton() 0 1 ?
compileReplyButton() 0 1 ?
compileUrlButton() 0 1 ?
A compile() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Drivers;
6
7
use RuntimeException;
8
use FondBot\Contracts\Template;
9
use FondBot\Templates\Keyboard;
10
use FondBot\Templates\Keyboard\UrlButton;
11
use FondBot\Templates\Keyboard\ReplyButton;
12
use FondBot\Templates\Keyboard\PayloadButton;
13
14
abstract class TemplateCompiler
15
{
16
    abstract public function compileKeyboard(Keyboard $keyboard);
17
18
    abstract public function compilePayloadButton(PayloadButton $button);
19
20
    abstract public function compileReplyButton(ReplyButton $button);
21
22
    abstract public function compileUrlButton(UrlButton $button);
23
24
    /**
25
     * Compile template.
26
     *
27
     * @param Template $template
28
     *
29
     * @return mixed
30
     *
31
     * @throws RuntimeException
32
     */
33 2
    public function compile(Template $template)
34
    {
35 2
        $method = 'compile'.ucfirst($template->getName());
36 2
        if (!method_exists($this, $method)) {
37 1
            throw new RuntimeException('No compile method for "'.$template->getName().'".');
38
        }
39
40 1
        return $this->$method($template);
41
    }
42
}
43