Passed
Push — main ( 1f9a40...3e1577 )
by Stefan
01:51
created

FormScript   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 6
dl 0
loc 19
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHTML() 0 4 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SKien\Formgenerator;
5
6
/**
7
 * Class to insert a script tag inside of the form.  
8
 *
9
 * #### History
10
 * - *2021-02-12*   initial version
11
 *
12
 * @package Formgenerator
13
 * @version 1.1.0
14
 * @author Stefanius <[email protected]>
15
 * @copyright MIT License - see the LICENSE file for details
16
 */
17
class FormScript extends FormElement
18
{
19
    /** @var string text for the line label     */
20
    protected string $strScript;
21
    
22
    public function __construct(string $strScript)
23
    {
24
        parent::__construct(0);
25
        $this->strScript = $strScript;
26
    }
27
28
    /**
29
     * Just insert the script at current position of the form.
30
     * @return string
31
     */
32
    public function getHTML() : string
33
    {
34
        $strHTML  = '<script>' . $this->strScript . '</Script>' . PHP_EOL;
35
        return $strHTML;
36
    }
37
}
38