Completed
Branch FET-10580-form-html-parser (9e1c68)
by
unknown
210:04 queued 197:24
created

VsprintfParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A parseHtml() 0 5 1
1
<?php
2
namespace EventEspresso\core\libraries\form_sections\strategies\parser;
3
4
defined('EVENT_ESPRESSO_VERSION') || exit;
5
6
7
8
/**
9
 * Class SprintfFormHtmlParser
10
 * parses a form section's rendered HTML using vsprintf()
11
 * PLZ NOTE: the rendered HTML will be the LAST argument in the array of args passed to vsprintf()
12
 *
13
 * @package       Event Espresso
14
 * @author        Brent Christensen
15
 * @since         $VID:$
16
 */
17
class VsprintfParser extends FormHtmlParser
18
{
19
20
    /**
21
     * @var string $format
22
     */
23
    protected $format = '';
24
25
26
    /**
27
     * @var array $args
28
     */
29
    protected $args = array();
30
31
32
33
    /**
34
     * SprintfFormHtmlParser constructor.
35
     *
36
     * @param string $format
37
     * @param array  $args
38
     */
39
    public function __construct($format, array $args)
40
    {
41
        $this->format = $format;
42
        $this->args = $args;
43
    }
44
45
46
47
    /**
48
     * @param string $html
49
     * @return int
50
     */
51
    public function parseHtml($html = '')
52
    {
53
        $this->args[] = $html;
54
        return vprintf($this->format, $this->args);
55
    }
56
57
58
59
}
60
// End of file SprintfFormHtmlParser.php
61
// Location: EventEspresso\core\libraries\form_sections\strategies\parser/SprintfFormHtmlParser.php