SmartFormTextElement::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 9

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 9
nop 2
dl 0
loc 15
rs 9.4555
c 0
b 0
f 0
1
<?php namespace XoopsModules\Smartobject\Form\Elements;
2
3
/**
4
 * Contains the SmartObjectControl class
5
 *
6
 * @license    GNU
7
 * @author     marcan <[email protected]>
8
 * @link       http://smartfactory.ca The SmartFactory
9
 * @package    SmartObject
10
 * @subpackage SmartObjectForm
11
 */
12
13
use XoopsModules\Smartobject;
14
15
/**
16
 * Class SmartFormTextElement
17
 * @package XoopsModules\Smartobject\Form\Elements
18
 */
19
class SmartFormTextElement extends \XoopsFormText
20
{
21
    /**
22
     * SmartFormTextElement constructor.
23
     * @param string $object
24
     * @param string $key
25
     */
26
    public function __construct($object, $key)
27
    {
28
        $var = $object->vars[$key];
29
30
        if (isset($object->controls[$key])) {
31
            $control        = $object->controls[$key];
32
            $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255);
33
            $form_size      = isset($control['size']) ? $control['size'] : 50;
34
        } else {
35
            $form_maxlength = 255;
36
            $form_size      = 50;
37
        }
38
39
        parent::__construct($var['form_caption'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e'));
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $object (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
40
    }
41
}
42