ImageCarouselColumnTemplateBuilder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace LineMob\Core\LineCorp\LINEBot\MessageBuilder\TemplateBuilder;
4
5
use LINE\LINEBot\MessageBuilder\TemplateBuilder;
6
use LINE\LINEBot\TemplateActionBuilder;
7
8
/**
9
 * remove this when 'linecorp/line-bot-sdk' updated
10
 */
11
class ImageCarouselColumnTemplateBuilder implements TemplateBuilder
12
{
13
    /** @var string */
14
    private $imageUrl;
15
16
    /** @var TemplateActionBuilder */
17
    private $actionBuilder;
18
19
    /** @var array */
20
    private $template;
21
22
    /**
23
     * ImageCarouselColumnTemplateBuilder constructor.
24
     *
25
     * @param string $imageUrl
26
     * @param TemplateActionBuilder $actionBuilder
27
     */
28
    public function __construct($imageUrl, $actionBuilder)
29
    {
30
        $this->imageUrl = $imageUrl;
31
        $this->actionBuilder = $actionBuilder;
32
    }
33
34
    /**
35
     * Builds column of carousel template structure.
36
     *
37
     * @return array
38
     */
39
    public function buildTemplate()
40
    {
41
        if (!empty($this->template)) {
42
            return $this->template;
43
        }
44
45
        $this->template = [
46
            'imageUrl' => $this->imageUrl,
47
            'action' => $this->actionBuilder->buildTemplateAction(),
48
        ];
49
50
        return $this->template;
51
    }
52
}
53