menu_entries()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 149
Code Lines 73

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 73
nc 1
nop 0
dl 0
loc 149
rs 8.589
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
function menu_current(): string
4
{
5
    return $_GET['exp'] ?? '';
6
}
7
8
function menu_url(string $example): string
9
{
10
    return "/?exp=$example";
11
}
12
13
function menu_entries()
14
{
15
    return [
16
        'calculator' => [
17
            'title' => 'Calculator',
18
            'desc' => '<p>
19
In this example, a calculator is implemented as a Jaxon component, which is inserted at a given position in the page.
20
</p>
21
<p>
22
The result of the operation is computed by a service which is injected in the main component, and formatted by another component.
23
</p>',
24
        ],
25
        'hello' => [
26
            'title' => 'Hello World Function',
27
            'desc' => '<p>
28
This example shows how to export a function with Jaxon.
29
</p>',
30
        ],
31
        'alias' => [
32
            'title' => 'Hello World Alias',
33
            'desc' => '<p>
34
This example shows how to set an alias to an exported function with Jaxon.
35
</p>',
36
        ],
37
        'class' => [
38
            'title' => 'Hello World Class',
39
            'desc' => '<p>
40
This example shows how to export a class with Jaxon.
41
</p>',
42
        ],
43
        'export' => [
44
            'title' => 'Export Javascript',
45
            'desc' => '<p>
46
This example shows how to export the generated javascript code in an external file, which is then loaded into the webpage.
47
</p>',
48
        ],
49
        'confirm' => [
50
            'title' => 'Confirm question',
51
            'desc' => '',
52
        ],
53
        'pagination' => [
54
            'title' => 'Pagination',
55
            'desc' => '',
56
        ],
57
        'html-attributes' => [
58
            'title' => 'Jaxon HTML attributes',
59
            'desc' => '<p>
60
This example shows how to use Jaxon HTML custom attributes to attach a component to a DOM node, and define event handlers.
61
</p>',
62
        ],
63
        'event-parent' => [
64
            'title' => 'Children event handlers',
65
            'desc' => '<p>
66
This example shows how to use Jaxon HTML custom attributes to define event handlers on child DOM nodes.
67
</p>',
68
        ],
69
        'event-target' => [
70
            'title' => 'Multiple event handlers',
71
            'desc' => '<p>
72
This example shows how to use Jaxon HTML custom attributes to define multiple event handlers on a single DOM node.
73
</p>',
74
        ],
75
        'bind-component' => [
76
            'title' => 'Bind a component',
77
            'desc' => '<p>
78
This example shows how to dynamically bind a component to a DOM node.
79
</p>',
80
        ],
81
        'outerhtml-component' => [
82
            'title' => 'Attributes in outerHTML',
83
            'desc' => '<p>
84
This example shows how to dynamically bind a component to a DOM node by setting its outerHTML property.
85
</p>',
86
        ],
87
        'pagination-component' => [
88
            'title' => 'Pagination component',
89
            'desc' => 'This example demonstrates the built-in pagination component.',
90
        ],
91
        'pagination-databag' => [
92
            'title' => 'Pagination and databag',
93
            'desc' => 'In this example the built-in pagination component in used with a data bag.',
94
        ],
95
        'plugins' => [
96
            'title' => 'Plugin Usage',
97
            'desc' => '<p>
98
The example shows the use of Jaxon plugins, by adding javascript notifications and modal windows to the class.php
99
example with the jaxon-toastr, jaxon-pgwjs and jaxon-bootstrap packages.
100
</p>
101
<p>
102
Using an Jaxon plugin is very simple. After a plugin is installed with Composer, its automatically registers into
103
the Jaxon core library. It can then be accessed both in the Jaxon main object, for configuration, and in the Jaxon
104
response object, to provide additional functionalities to the application.
105
</p>',
106
        ],
107
        'dialogs' => [
108
            'title' => 'Dialogs',
109
            'desc' => '',
110
        ],
111
        'flot' => [
112
            'title' => 'Flot Plugin',
113
            'desc' => '',
114
        ],
115
        'config' => [
116
            'title' => 'Config File',
117
            'desc' => '',
118
        ],
119
        'directories' => [
120
            'title' => 'Register Directories',
121
            'desc' => '<p>
122
This example shows how to automatically register all the PHP classes in a set of directories.
123
</p>
124
<p>
125
The classes in this example are not namespaced, thus they all need to have different names, even if they are in different subdirs.
126
</p>',
127
        ],
128
        'namespaces' => [
129
            'title' => 'Register Namespaces',
130
            'desc' => '<p>
131
This example shows how to automatically register all the classes in a set of directories with namespaces.
132
</p>
133
<p>
134
The namespace is prepended to the generated javascript class names, and PHP classes in different subdirs can have the same name.
135
</p>',
136
        ],
137
        'container' => [
138
            'title' => 'DI container',
139
            'desc' => '',
140
        ],
141
        'package' => [
142
            'title' => 'Package',
143
            'desc' => '',
144
        ],
145
        'autoload-default' => [
146
            'title' => 'Default Autoloader',
147
            'desc' => '<p>
148
This example illustrates the use of the Composer autoloader.
149
</p>
150
<p>
151
By default, the Jaxon library implements a simple autoloading mechanism by require_once\'ing the corresponding PHP file
152
for each missing class.
153
</p>
154
<p>
155
When provided with the Composer autoloader, the Jaxon library registers all directories with a namespace
156
into the PSR-4 autoloader, and it registers all the classes in directories with no namespace into the classmap autoloader.
157
</p>',
158
        ],
159
        'autoload-disabled' => [
160
            'title' => 'Third Party Autoloader',
161
            'desc' => '<p>
162
In this example the autoloading is disabled in the Jaxon library.
163
</p>
164
<p>
165
A third-party autoloader is used to load the Jaxon classes.
166
</p>',
167
        ],
168
    ];
169
}
170