Votes::getForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Songlist;
4
5
require_once \dirname(__DIR__) . '/include/songlist.object.php';
6
// require_once \dirname(__DIR__) . '/include/songlist.form.php';
7
use  XoopsModules\Songlist\Form\FormController;
8
9
10
11
/**
12
 * Class Votes
13
 */
14
class Votes extends \XoopsObject
15
{
16
    /**
17
     * Votes constructor.
18
     * @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...
19
     */
20
    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

20
    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...
21
    {
22
        $this->initVar('vid', \XOBJ_DTYPE_INT, 0, false);
23
        $this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
24
        $this->initVar('uid', \XOBJ_DTYPE_INT, 0, false);
25
        $this->initVar('ip', \XOBJ_DTYPE_TXTBOX, null, false, 64);
26
        $this->initVar('netaddy', \XOBJ_DTYPE_TXTBOX, null, false, 255);
27
        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
28
    }
29
30
    /**
31
     * @param bool $as_array
32
     * @return array|string
33
     */
34
    public function getForm($as_array = false)
35
    {
36
        return FormController::votes_get_form($this, $as_array);
0 ignored issues
show
Bug introduced by
The method votes_get_form() does not exist on XoopsModules\Songlist\Form\FormController. ( Ignorable by Annotation )

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

36
        return FormController::/** @scrutinizer ignore-call */ votes_get_form($this, $as_array);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
    }
38
39
    /**
40
     * @return array
41
     */
42
    public function toArray(): array
43
    {
44
        $ret  = parent::toArray();
45
        $form = $this->getForm(true);
46
        foreach ($form as $key => $element) {
47
            $ret['form'][$key] = $element->render();
48
        }
49
50
        $ret['rank'] = \number_format($this->getVar('rank'), 2) . \_MI_SONGLIST_OFTEN;
51
52
        return $ret;
53
    }
54
}
55