Passed
Push — master ( 005d4f...8b5e26 )
by Michael
06:49
created

DateSelect::showField()   A

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 0
dl 0
loc 3
rs 10
1
<?php
2
namespace XoopsModules\Pedigree;
3
4
/*
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 */
13
14
/**
15
 * @package         XoopsModules\Pedigree
16
 * @copyright       {@link https://xoops.org/ XOOPS Project}
17
 * @license         {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
18
 * @author          XOOPS Module Dev Team
19
 */
20
use XoopsModules\Pedigree\{
21
    Animal,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModules\Pedigree\Animal. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
22
    Field
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModules\Pedigree\Field. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
23
};
24
25
/**
26
 * Class Pedigree\DateSelectBox
27
 */
28
class DateSelect extends Pedigree\HtmlInputAbstract
0 ignored issues
show
Bug introduced by
The type XoopsModules\Pedigree\Pedigree\HtmlInputAbstract 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...
29
{
30
    // Define class variables
31
    private $fieldnumber;
32
    private $fieldname;
33
    private $value;
34
    private $defaultvalue;
35
    private $lookuptable;
36
    private $errs;
37
    private $size = 15;
38
39
    /**
40
     * Constructor
41
     *
42
     * @param Field $parentObject
43
     * @param Animal $animalObject
44
     *
45
     */
46
    public function __construct(Field $parentObject, Animal $animalObject)
47
    {
48
        //@todo move language strings to language file
49
        $this->fieldnumber = $parentObject->getId();
50
        $this->fieldname = $parentObject->getSetting('fieldname');
51
        $this->value = $animalObject->{'user' . $this->fieldnumber};
52
        $this->defaultvalue = $parentObject->getSetting('defaultvalue');
53
        if ($parentObject->hasLookup()) {
54
            xoops_error('No lookuptable may be specified for userfield ' . $this->fieldnumber, get_class($this));
55
        }
56
        if ($parentObject->inAdvanced()) {
57
            xoops_error('userfield ' . $this->fieldnumber . ' cannot be shown in advanced info', get_class($this));
58
        }
59
        if ($parentObject->inPie()) {
60
            xoops_error('A Pie-chart cannot be specified for userfield ' . $this->fieldnumber, get_class($this));
61
        }
62
    }
63
64
    /**
65
     * @return \XoopsFormTextDateSelect
66
     */
67
    public function editField(): \XoopsFormTextDateSelect
68
    {
69
        return new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', 'user' . $this->fieldnumber, $this->size, $this->value);
70
    }
71
72
    /**
73
     * @param string $name
74
     *
75
     * @return \XoopsFormTextDateSelect
76
     */
77
    public function newField(?string $name = ''): \XoopsFormTextDateSelect
78
    {
79
        return new \XoopsFormTextDateSelect('<b>' . $this->fieldname . '</b>', $name . 'user' . $this->fieldnumber, $this->size, $this->defaultvalue);
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getSearchString()
86
    {
87
        return '&amp;o=naam&amp;l=1';
88
    }
89
90
    /**
91
     * Show the value - which is nothing for this data type
92
     */
93
    public function showValue()
94
    {
95
96
    }
97
}
98