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

TemplateCompiler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

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