Passed
Branch master (48d769)
by Michael
02:30
created

TextBox   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A editField() 0 5 1
A newField() 0 5 1
A getSearchString() 0 3 1
A __construct() 0 15 4
1
<?php namespace XoopsModules\Pedigree;
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
/**
12
 * Pedigree module for XOOPS
13
 *
14
 * @copyright   {@link http://sourceforge.net/projects/thmod/ The TXMod XOOPS Project}
15
 * @copyright   {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
16
 * @license     GPL 2.0 or later
17
 * @package     pedigree
18
 * @subpackage  class
19
 * @author      XOOPS Mod Development Team
20
 */
21
22
use XoopsModules\Pedigree;
23
24
25
/**
26
 * Class Pedigree\SelectBox
27
 */
28
class TextBox extends Pedigree\HtmlInputAbstract
29
{
30
    // Define class variables
31
    private $fieldnumber;
32
    private $fieldname;
33
    private $value;
34
    private $defaultvalue;
35
    private $lookuptable;
36
37
    /**
38
     * Constructor
39
     *
40
     * @param $parentObject
41
     * @param $animalObject
42
     */
43
    public function __construct($parentObject, $animalObject)
44
    {
45
        $this->fieldnumber  = $parentObject->getId();
46
        $this->fieldname    = $parentObject->fieldname;
47
        $this->value        = $animalObject->{'user' . $this->fieldnumber};
48
        $this->defaultvalue = $parentObject->defaultvalue;
49
        $this->lookuptable  = $parentObject->lookuptable;
50
        if ('1' == $this->lookuptable) {
51
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, get_class($this));
0 ignored issues
show
Bug introduced by
The function xoops_error was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

51
            /** @scrutinizer ignore-call */ 
52
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, get_class($this));
Loading history...
52
        }
53
        if ('1' == $parentObject->viewinadvanced) {
54
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
55
        }
56
        if ('1' == $parentObject->viewinpie) {
57
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
58
        }
59
    }
60
61
    /**
62
     * @return \XoopsFormText
63
     */
64
    public function editField()
65
    {
66
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->value);
0 ignored issues
show
Bug introduced by
The type XoopsFormText was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
67
68
        return $textbox;
69
    }
70
71
    /**
72
     * @param string $name
73
     *
74
     * @return \XoopsFormText
75
     */
76
    public function newField($name = '')
77
    {
78
        $textbox = new \XoopsFormText('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $size = 50, $maxsize = 50, $value = $this->defaultvalue);
79
80
        return $textbox;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getSearchString()
87
    {
88
        return '&amp;o=naam&amp;l=1';
89
    }
90
}
91