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 | 8 | public function process() : ?string |
|
28 | { |
||
29 | 8 | $settingModel = new Model\Setting(); |
|
30 | 8 | $lastTable = $this->_registry->get('lastTable'); |
|
31 | 8 | $lastId = $this->_registry->get('lastId'); |
|
32 | 8 | $useTitle = $this->_registry->get('useTitle'); |
|
33 | 8 | $settingDivider = $settingModel->get('divider'); |
|
34 | 8 | $settingTitle = $settingModel->get('title'); |
|
35 | 8 | $title = null; |
|
36 | |||
37 | /* find title */ |
||
38 | |||
39 | 8 | if ($useTitle) |
|
40 | { |
||
41 | 1 | $title = $useTitle; |
|
42 | } |
||
43 | 7 | else if ($lastTable && $lastId) |
|
44 | { |
||
45 | 5 | $content = Db::forTablePrefix($lastTable)->whereIdIs($lastId)->findOne(); |
|
0 ignored issues
–
show
|
|||
46 | 5 | $title = $content->title; |
|
47 | 5 | if ($title) |
|
48 | { |
||
49 | 5 | $title .= $settingDivider . $settingTitle; |
|
50 | } |
||
51 | } |
||
52 | |||
53 | /* handle title */ |
||
54 | |||
55 | 8 | if ($title) |
|
56 | { |
||
57 | 6 | return $title; |
|
58 | } |
||
59 | 2 | return $settingTitle; |
|
60 | } |
||
61 | } |
||
62 |
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.