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

Title::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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 redaxmedia
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