Completed
Push — master ( 49fe65...7ce6e8 )
by WEBEWEB
01:52
created

AbstractFormTwigExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootstrapInputMask() 0 8 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\Form;
13
14
use WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractBootstrapTwigExtension;
15
use WBW\Library\Core\Utility\StringUtility;
16
17
/**
18
 * Abstract form Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Form
22
 * @abstract
23
 */
24
abstract class AbstractFormTwigExtension extends AbstractBootstrapTwigExtension {
25
26
    /**
27
     * Displays a Bootstrap input mask.
28
     *
29
     * @param string $selector The input mask selector.
30
     * @param array $arguments The input mask arguments.
31
     * @return string Returns the Bootstrap input mask.
32
     */
33
    final protected function bootstrapInputMask($selector, array $arguments) {
34
35
        // Initialize the template.
36
        $template = "$('%selector%').inputmask(%arguments%);";
37
38
        // Return the HTML.
39
        return StringUtility::replace($template, ["%selector%", "%arguments%"], [$selector, json_encode($arguments)]);
40
    }
41
42
}
43