Completed
Push — master ( 0ea243...da58d4 )
by Henry
10:25 queued 33s
created

includes/Head/Title.php (1 issue)

Upgrade to new PHP Analysis Engine

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\Head;
3
4
use Redaxscript\Html;
5
6
/**
7
 * children class to create the title tag
8
 *
9
 * @since 3.0.0
10
 *
11
 * @package Redaxscript
12
 * @category Head
13
 * @author Henry Ruhs
14
 * @author Balázs Szilágyi
15
 */
16
17
class Title implements HeadInterface
18
{
19
	/**
20
	 * render the title
21
	 *
22
	 * @since 3.0.0
23
	 *
24
	 * @param string $text
25
	 *
26
	 * @return string|null
27
	 */
28
29
	public function render(string $text = null) : ?string
30
	{
31
		if ($text)
0 ignored issues
show
Bug Best Practice introduced by
The expression $text of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
32
		{
33
			$titleElement = new Html\Element();
34
			return $titleElement
35
				->init('title')
36 2
				->text($text)
37
				->render();
38 2
		}
39 2
		return null;
40
	}
41
}
42