Passed
Push — master ( cf57bc...9eba79 )
by Michael
01:41
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 render() 0 14 3
A __construct() 0 3 1
A addLink() 0 5 1
1
<?php namespace XoopsModules\Gbook\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 31 and the first side effect is on line 26.

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
 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
 * Breadcrumb Class
13
 *
14
 * @copyright   XOOPS Project (https://xoops.org)
15
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @author      lucio <[email protected]>
17
 * @package     gbook
18
 *
19
 * Example:
20
 * $breadcrumb = new PedigreeBreadcrumb();
21
 * $breadcrumb->addLink( 'bread 1', 'index1.php' );
22
 * $breadcrumb->addLink( 'bread 2', '' );
23
 * $breadcrumb->addLink( 'bread 3', 'index3.php' );
24
 * echo $breadcrumb->render();
25
 */
26
defined('XOOPS_ROOT_PATH') || die('XOOPS Root Path not defined');
27
28
/**
29
 * Class Breadcrumb
30
 */
31
class Breadcrumb
32
{
33
    public $dirname;
34
    private $bread = [];
35
36
    /**
37
     *
38
     */
39
    public function __construct()
40
    {
41
        $this->dirname = basename(dirname(__DIR__));
42
    }
43
44
    /**
45
     * Add link to breadcrumb
46
     *
47
     * @param string $title
48
     * @param string $link
49
     */
50
    public function addLink($title = '', $link = '')
51
    {
52
        $this->bread[] = [
53
            'link'  => $link,
54
            'title' => $title
55
        ];
56
    }
57
58
    /**
59
     * Render Pedigree BreadCrumb
60
     *
61
     */
62
    public function render()
63
    {
64
        if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
65
            require_once $GLOBALS['xoops']->path('class/theme.php');
66
            $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...
67
        }
68
69
        require_once $GLOBALS['xoops']->path('class/template.php');
70
        $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...
71
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
72
        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
73
        unset($breadcrumbTpl);
74
75
        return $html;
76
    }
77
}
78