Completed
Push — master ( 4d5688...be014c )
by WEBEWEB
01:51
created

AbstractImageTwigExtension::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
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 WBW\Bundle\BootstrapBundle\Twig\Extension\CSS;
13
14
use WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractTwigExtension;
15
use WBW\Library\Core\Argument\StringHelper;
16
17
/**
18
 * Abstract image Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\CSS
22
 * @abstract
23
 */
24
abstract class AbstractImageTwigExtension extends AbstractTwigExtension {
25
26
    /**
27
     * Displays a Bootstrap image.
28
     *
29
     * @param string $src The source
30
     * @param string $alt The alternative text.
31
     * @param string $width The width.
32
     * @param string $height The height.
33
     * @param string $class The class.
34
     * @param string $usemap The usemap.
35
     * @return string Returns the Bootstrap image.
36
     */
37
    protected function bootstrapImage($src, $alt, $width, $height, $class, $usemap) {
38
39
        $template = "<img %attributes%/>";
40
41
        $attributes = [];
42
43
        $attributes["src"]    = $src;
44
        $attributes["alt"]    = $alt;
45
        $attributes["width"]  = $width;
46
        $attributes["height"] = $height;
47
        $attributes["class"]  = $class;
48
        $attributes["usemap"] = $usemap;
49
50
        return StringHelper::replace($template, ["%attributes%"], [StringHelper::parseArray($attributes)]);
51
    }
52
}
53