Passed
Push — develop ( b546ed...ec145b )
by Felipe
08:20
created

FormTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getActionTableAndButtons() 0 9 1
1
<?php
2
3
/**
4
 * PHPPgAdmin v6.0.0-beta.48
5
 */
6
7
namespace PHPPgAdmin\Traits;
8
9
/**
10
 * Common trait to print form parts that appear on different controller dialogs.
11
 */
12
trait FormTrait
13
{
14
    public $misc;
15
16
    /**
17
     * Prints inputs for action, table and submit/cancel buttons.
18
     *
19
     * @param string $action value for action input
20
     * @param string $table  value for table input
21
     * @param string $add    text for add button
22
     * @param string $cancel text for cancel button
23
     */
24
    public function getActionTableAndButtons($action, $table, $add, $cancel)
25
    {
26
        $content = $this->misc->form;
27
        $content .= sprintf('<input type="hidden" name="action" value="%s" />%s', $action, "\n");
28
        $content .= sprintf('<input type="hidden" name="table" value="%s" />%s', $table, "\n");
29
        $content .= sprintf('<input type="submit" value="%s" />%s', $add, "\n");
30
        $content .= sprintf('<input type="submit" name="cancel" value="%s" />', $cancel);
31
32
        return $content;
33
    }
34
}
35