Utf8map   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getForm() 0 3 1
A toArray() 0 15 4
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Songlist;
4
5
use XoopsObject;
6
7
\defined('XOOPS_ROOT_PATH') || exit('Restricted access');
8
9
require_once \dirname(__DIR__) . '/include/songlist.object.php';
10
// require_once \dirname(__DIR__) . '/include/songlist.form.php';
11
use  XoopsModules\Songlist\Form\FormController;
12
13
/**
14
 * Class Utf8map
15
 */
16
class Utf8map extends XoopsObject
17
{
18
    /**
19
     * Utf8map constructor.
20
     * @param null $fid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fid is correct as it would always require null to be passed?
Loading history...
21
     */
22
    public function __construct($fid = null)
0 ignored issues
show
Unused Code introduced by
The parameter $fid is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    public function __construct(/** @scrutinizer ignore-unused */ $fid = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        $this->initVar('utfid', \XOBJ_DTYPE_INT, 0, false);
25
        $this->initVar('from', \XOBJ_DTYPE_TXTBOX, null, false, 2);
26
        $this->initVar('to', \XOBJ_DTYPE_TXTBOX, null, false, 2);
27
        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
28
        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
29
    }
30
31
    /**
32
     * @param bool $as_array
33
     * @return array|string
34
     */
35
    public function getForm($as_array = false)
36
    {
37
        return FormController::getFormUtf8map($this, $as_array);
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function toArray(): array
44
    {
45
        $ret  = parent::toArray();
46
        $form = $this->getForm(true);
47
        foreach ($form as $key => $element) {
48
            $ret['form'][$key] = $element->render();
49
        }
50
        foreach (['created', 'updated'] as $key) {
51
            if ($this->getVar($key) > 0) {
52
                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
53
                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
54
            }
55
        }
56
57
        return $ret;
58
    }
59
}
60