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