AmazonHandler::draw()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Kaloa\Renderer\Inigo\Handler;
4
5
use Kaloa\Renderer\Inigo\Handler\ProtoHandler;
6
use Kaloa\Renderer\Inigo\Parser;
7
8
/**
9
 *
10
 */
11
final class AmazonHandler extends ProtoHandler
12
{
13
    /**
14
     *
15
     */
16 18
    public function __construct()
17
    {
18 18
        $this->name = 'amazon';
19 18
        $this->type = Parser::TAG_OUTLINE;
20 18
    }
21
22
    /**
23
     *
24
     * @param  string $asin
25
     * @param  string $title
26
     * @param  string $author
27
     * @return string
28
     */
29 1
    private function drawBox($asin, $title, $author)
30
    {
31 1
        $img = 'http://images.amazon.com/images/P/' . $this->e($asin)
32 1
                . '.01._SCMZZZZZZZ_V65020934_.jpg';
33
34
        $ret = '<div class="amazon clear">'
35
                . '<div class="img-border">'
36 1
                . '<div class="img" style="background-image: url(' . $this->e($img) . ');"></div>'
37 1
                . '</div>'
38 1
                . '<p class="title"><strong>' . $this->e($title) . '</strong></p>'
39 1
                . '<p class="author">' . $this->e($author) . '</p>'
40 1
                . '</div>';
41
42 1
        return $ret;
43
    }
44
45
    /**
46
     *
47
     * @param  array  $data
48
     * @return string
49
     */
50 1
    public function draw(array $data)
51
    {
52 1
        $ret = '';
53
54 1
        if ($data['front']) {
55 1
            $asin   = $this->fillParam($data, 'asin', '');
56 1
            $title  = $this->fillParam($data, 'title', '');
57 1
            $author = $this->fillParam($data, 'author', '');
58
59 1
            $ret = $this->drawBox($asin, $title, $author);
60 1
        }
61
62 1
        return $ret;
63
    }
64
}
65