Passed
Push — master ( 1bc300...987c24 )
by Michael
01:47
created

Breadcrumb   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addLink() 0 5 1
A render() 0 14 3
A __construct() 0 3 1
1
<?php namespace XoopsModules\Moduleinstaller\Common;
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 32 and the first side effect is on line 27.

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
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * Breadcrumb Class
14
 *
15
 * @copyright   XOOPS Project (https://xoops.org)
16
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
17
 * @author      lucio <[email protected]>
18
 * @package     moduleinstaller
19
 *
20
 * Example:
21
 * $breadcrumb = new PedigreeBreadcrumb();
22
 * $breadcrumb->addLink( 'bread 1', 'index1.php' );
23
 * $breadcrumb->addLink( 'bread 2', '' );
24
 * $breadcrumb->addLink( 'bread 3', 'index3.php' );
25
 * echo $breadcrumb->render();
26
 */
27
defined('XOOPS_ROOT_PATH') || die('XOOPS Root Path not defined');
28
29
/**
30
 * Class Breadcrumb
31
 */
32
class Breadcrumb
33
{
34
    public $dirname;
35
    private $bread = [];
36
37
    /**
38
     *
39
     */
40
    public function __construct()
41
    {
42
        $this->dirname = basename(dirname(__DIR__));
43
    }
44
45
    /**
46
     * Add link to breadcrumb
47
     *
48
     * @param string $title
49
     * @param string $link
50
     */
51
    public function addLink($title = '', $link = '')
52
    {
53
        $this->bread[] = [
54
            'link'  => $link,
55
            'title' => $title
56
        ];
57
    }
58
59
    /**
60
     * Render Pedigree BreadCrumb
61
     *
62
     */
63
    public function render()
64
    {
65
        if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
66
            require_once $GLOBALS['xoops']->path('class/theme.php');
67
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
0 ignored issues
show
Bug introduced by
The type xos_opal_Theme 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...
68
        }
69
70
        require_once $GLOBALS['xoops']->path('class/template.php');
71
        $breadcrumbTpl = new \XoopsTpl();
0 ignored issues
show
Bug introduced by
The type XoopsTpl 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...
72
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
73
        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
74
        unset($breadcrumbTpl);
75
76
        return $html;
77
    }
78
}
79