Completed
Branch master (d2c4e1)
by
unknown
09:55 waited 07:09
created

Title::render()   A

↳ Parent: Title

Complexity

Conditions 2
Paths 2

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 12
Code Lines 8

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 1
cts 1
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
namespace Redaxscript\Head;
3
4
use Redaxscript\Html;
5
use Redaxscript\Registry;
6
7
/**
8
 * children class to create the title tag
9
 *
10
 * @since 3.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Head
14
 * @author Henry Ruhs
15
 * @author Balázs Szilágyi
16
 */
17
18
class Title implements HeadInterface
19
{
20
	/**
21
	 * instance of the registry class
22
	 *
23
	 * @var object
24
	 */
25
26
	protected $_registry;
27
28
	/**
29
	 * constructor of the class
30
	 *
31
	 * @since 3.0.0
32
	 *
33
	 * @param Registry $registry instance of the registry class
34
	 */
35
36
	public function __construct(Registry $registry)
37 4
	{
38
		$this->_registry = $registry;
39 4
	}
40 4
41
	/**
42
	 * render the title
43
	 *
44
	 * @since 3.0.0
45
	 *
46
	 * @param string $text
47
	 *
48
	 * @return string
49
	 */
50 3
51
	public function render($text = null)
52 3
	{
53
		$titleElement = new Html\Element();
54
		$titleElement->init();
55
		if ($text)
0 ignored issues
show
Bug Best Practice introduced by redaxmedia
The expression $text of type string|null 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...
56
		{
57
			return $titleElement
58
				->init('title')
59
				->text($text)
60
				->render();
61
		}
62
	}
63
}