SmartFormImageUploadElement::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 6
loc 6
rs 10
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
//require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformuploadelement.php';
16
17
/**
18
 * Class SmartFormImageUploadElement
19
 */
20 View Code Duplication
class SmartFormImageUploadElement extends Smartobject\Form\Elements\SmartFormUploadElement
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * SmartFormImageUploadElement constructor.
24
     * @param string $object
25
     * @param string $key
26
     */
27
    public function __construct($object, $key)
28
    {
29
        $this->SmartFormFileElement($object, $key);
30
        // Override name for upload purposes
31
        $this->setName('upload_' . $key);
32
    }
33
34
    /**
35
     * prepare HTML for output
36
     *
37
     * @return string HTML
38
     */
39
    public function render()
40
    {
41
        return "<input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'>
42
        <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . ">
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
43
        <input type='hidden' name='smart_upload_image[]' id='smart_upload_image[]' value='" . $this->getName() . "'>";
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
44
    }
45
}
46