Breadcrumb   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 7
dl 0
loc 33
rs 10
c 1
b 1
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A render() 0 2 1
A addLink() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Tag\Common;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * Breadcrumb Class
17
 *
18
 * @copyright   XOOPS Project (https://xoops.org)
19
 * @license     https://www.fsf.org/copyleft/gpl.html GNU public license
20
 * @author      lucio <[email protected]>
21
 *
22
 * Example:
23
 * $breadcrumb = new \XoopsModules\Tag\Breadcrumb();
24
 * $breadcrumb->addLink( 'bread 1', 'index1.php' );
25
 * $breadcrumb->addLink( 'bread 2', '' );
26
 * $breadcrumb->addLink( 'bread 3', 'index3.php' );
27
 * echo $breadcrumb->render();
28
 */
29
30
/**
31
 * Class Breadcrumb
32
 */
33
class Breadcrumb
34
{
35
    /**
36
     * @var string
37
     */
38
    public $dirname;
39
    /**
40
     * @var array
41
     */
42
    private $bread;
43
44
    public function __construct()
45
    {
46
        $this->dirname = \basename(\dirname(__DIR__, 2));
47
    }
48
49
    /**
50
     * Add link to breadcrumb
51
     *
52
     */
53
    public function addLink(string $title = '', string $link = ''): void
54
    {
55
        $this->bread[] = [
56
            'link'  => $link,
57
            'title' => $title,
58
        ];
59
    }
60
61
    /**
62
     * Render BreadCrumb
63
     */
64
    public function render()
65
    {
66
        /*
67
        TODO if you want to use the render code below,
68
        1) create ./templates/chess_common_breadcrumb.tpl)
69
        2) add declaration to  xoops_version.php
70
        */
71
        /*
72
        if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
73
            require $GLOBALS['xoops']->path('class/theme.php');
74
75
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
76
        }
77
78
        require $GLOBALS['xoops']->path('class/template.php');
79
80
        $breadcrumbTpl = new \XoopsTpl();
81
82
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
83
84
        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
85
86
        unset($breadcrumbTpl);
87
88
        return $html;
89
        */
90
    }
91
}
92