These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Template\Helper; |
||
3 | |||
4 | use Redaxscript\Db; |
||
5 | use Redaxscript\Model; |
||
6 | |||
7 | /** |
||
8 | * helper class to provide a title helper |
||
9 | * |
||
10 | * @since 3.0.0 |
||
11 | * |
||
12 | * @package Redaxscript |
||
13 | * @category Template |
||
14 | * @author Henry Ruhs |
||
15 | */ |
||
16 | |||
17 | class Title extends HelperAbstract |
||
18 | { |
||
19 | /** |
||
20 | * process |
||
21 | * |
||
22 | * @since 3.0.0 |
||
23 | * |
||
24 | * @return string|null |
||
25 | */ |
||
26 | |||
27 | public function process() : ?string |
||
28 | { |
||
29 | $settingModel = new Model\Setting(); |
||
30 | $firstParameter = $this->_registry->get('firstParameter'); |
||
31 | $secondParameter = $this->_registry->get('secondParameter'); |
||
32 | $adminParameter = $this->_registry->get('adminParameter'); |
||
33 | $tableParameter = $this->_registry->get('tableParameter'); |
||
34 | $lastTable = $this->_registry->get('lastTable'); |
||
35 | $lastId = $this->_registry->get('lastId'); |
||
36 | $useTitle = $this->_registry->get('useTitle'); |
||
37 | $settingDivider = $settingModel->get('divider'); |
||
38 | $settingTitle = $settingModel->get('title'); |
||
39 | $title = null; |
||
40 | |||
41 | /* find title */ |
||
42 | |||
43 | if ($useTitle) |
||
44 | { |
||
45 | $title = $useTitle; |
||
46 | } |
||
47 | |||
48 | /* handle admin */ |
||
49 | |||
50 | else if ($firstParameter === 'admin') |
||
51 | { |
||
52 | $title = $this->_language->get('administration'); |
||
53 | if ($adminParameter && $this->_language->get($adminParameter)) |
||
54 | { |
||
55 | $title .= $settingDivider . $this->_language->get($adminParameter); |
||
56 | if ($tableParameter && $this->_language->get($tableParameter)) |
||
57 | { |
||
58 | $title .= $settingDivider . $this->_language->get($tableParameter); |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 | |||
63 | /* handle login */ |
||
64 | |||
65 | else if ($firstParameter === 'login') |
||
66 | { |
||
67 | if ($secondParameter === 'recover') |
||
68 | { |
||
69 | $title = $this->_language->get('recovery'); |
||
70 | } |
||
71 | else if ($secondParameter === 'reset') |
||
72 | { |
||
73 | $title = $this->_language->get('reset'); |
||
74 | } |
||
75 | else |
||
76 | { |
||
77 | $title = $this->_language->get('login'); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | /* handle logout */ |
||
82 | |||
83 | else if ($firstParameter === 'logout') |
||
84 | { |
||
85 | $title = $this->_language->get('logout'); |
||
86 | } |
||
87 | |||
88 | /* handle register */ |
||
89 | |||
90 | else if ($firstParameter === 'register') |
||
91 | { |
||
92 | $title = $this->_language->get('registration'); |
||
93 | } |
||
94 | |||
95 | /* handle module */ |
||
96 | |||
97 | else if ($firstParameter === 'module') |
||
98 | { |
||
99 | $title = $this->_language->get('module'); |
||
100 | } |
||
101 | |||
102 | /* handle search */ |
||
103 | |||
104 | else if ($firstParameter === 'search') |
||
105 | { |
||
106 | $title = $this->_language->get('search'); |
||
107 | } |
||
108 | |||
109 | /* handle error */ |
||
110 | |||
111 | else if (!$lastId) |
||
112 | { |
||
113 | $title = $this->_language->get('error'); |
||
114 | } |
||
115 | else if ($lastTable && $lastId) |
||
116 | { |
||
117 | $title = Db::forTablePrefix($lastTable)->whereIdIs($lastId)->whereNull('access')->findOne()->title; |
||
0 ignored issues
–
show
|
|||
118 | } |
||
119 | |||
120 | /* handle title */ |
||
121 | |||
122 | if ($title && $settingTitle) |
||
123 | { |
||
124 | return $title . $settingDivider . $settingTitle; |
||
125 | } |
||
126 | return $title ? : $settingTitle; |
||
127 | } |
||
128 | } |
||
129 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.