Passed
Pull Request — master (#16)
by
unknown
02:10
created

ActionTemplateTrait::getTemplate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 18
rs 9.2
c 1
b 0
f 0
cc 4
eloc 12
nc 4
nop 0
1
<?php
2
3
/*
4
 * This file is part of the LineMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LineMob\Core\Template;
13
14
use LINE\LINEBot\TemplateActionBuilder\MessageTemplateActionBuilder;
15
use LINE\LINEBot\TemplateActionBuilder\PostbackTemplateActionBuilder;
16
use LINE\LINEBot\TemplateActionBuilder\UriTemplateActionBuilder;
17
18
/**
19
 * @author Ishmael Doss <[email protected]>
20
 *
21
 * @property array actions
22
 * @property string altText
23
 * @property string title
24
 */
25
trait ActionTemplateTrait
26
{
27
    /**
28
     * @return Action[]
29
     */
30 View Code Duplication
    private function createActions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $actions = [];
33
34
        foreach ($this->actions as $action) {
35
            switch (strtolower($action->type)) {
36
                case Action::TYPE_POSTBACK:
37
                    $actions[] = new PostbackTemplateActionBuilder($action->label, $action->value);
38
                    break;
39
                case Action::TYPE_URI:
40
                    $actions[] = new UriTemplateActionBuilder($action->label, $action->value);
41
                    break;
42
                default:
43
                    $actions[] = new MessageTemplateActionBuilder($action->label, $action->value);
44
            }
45
        }
46
47
        return $actions;
48
    }
49
}
50