Passed
Push — master ( b847d6...d6d54c )
by Michael
09:34 queued 05:00
created

HtmlInputAbstract::echoMsg()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php namespace XoopsModules\Pedigree;
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 31 and the first side effect is on line 16.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 *  pedigree HTML Input Interface Class Elements
5
 *
6
 * @copyright  ZySpec Incorporated
7
 * @license    {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
8
 * @package    pedigree
9
 * @subpackage class
10
 * @author     zyspec <[email protected]>
11
 * @since      1.3.1
12
 */
13
14
use XoopsModules\Pedigree;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModules\Pedigree\Pedigree. 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...
15
16
defined('XOOPS_ROOT_PATH') || die('Restricted access');
17
18
/**
19
 * Pedigree\HtmlInputAbstract
20
 *
21
 * @package   \XoopsModules\Pedigree\Class
22
 * @author    zyspec <[email protected]>
23
 * @copyright Copyright (c) 2014-2019 ZySpec Incorporated
24
 * @access    public
25
 */
26
27
28
/**
29
 * Class Pedigree\HtmlInputAbstract
30
 */
31
abstract class HtmlInputAbstract //extends Pedigree\Field
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
{
33
    /**
34
     * @return mixed
35
     */
36
    abstract public function editField();
37
38
    /**
39
     * @param $name
40
     * @return mixed
41
     */
42
    abstract public function newField($name);
43
44
    /**
45
     * @return mixed
46
     */
47
    abstract public function viewField();
48
49
    /**
50
     * @return mixed
51
     */
52
    abstract public function showField();
53
54
    /**
55
     * @return mixed
56
     */
57
    abstract public function showValue();
58
59
    /**
60
     * @return mixed
61
     */
62
    abstract public function searchField();
63
64
    /**
65
     * @return mixed
66
     */
67
    abstract public function getSearchString();
68
69
    /**
70
     * @param string $message
71
     *
72
     * @return void
73
     */
74
    public function echoMsg($message)
75
    {
76
        echo "<span style='color: red;'><h3>{$message}</h3></span>";
77
    }
78
79
    /**
80
     * @param $fieldnumber
81
     *
82
     * @return array
83
     */
84
    public function lookupField($fieldnumber)
85
    {
86
        $ret = [];
87
88
        /** @var \Xmf\Database\Tables $pTables */
89
        $pTables = new \Xmf\Database\Tables();
90
        $exists  = $pTables->useTable('pedigree_lookup' . $fieldnumber);
91
        if ($exists) {
92
            $tableName = $pTables->name('pedigree_lookup' . $fieldnumber);
93
            $SQL    = "SELECT * FROM `{$tableName}` ORDER BY 'order'";
94
            //$SQL    = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $fieldnumber) . " ORDER BY 'order'";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
95
            $result = $GLOBALS['xoopsDB']->query($SQL);
96
            while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
97
                $ret[] = ['id' => $row['id'], 'value' => $row['value']];
98
            }
99
        }
100
101
        //array_multisort($ret,SORT_ASC);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
102
        return $ret;
103
    }
104
}
105