RedirectAdapter::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Adapter for redirecting requests
4
 *
5
 * @file      RedirectAdapter.php
6
 *
7
 * PHP version 8.0+
8
 *
9
 * @author    Yancharuk Alexander <alex at itvault dot info>
10
 * @date      2017-02-19 23:16
11
 */
12
13
namespace Veles\View\Adapters;
14
15
/**
16
 * Class   RedirectAdapter
17
 *
18
 * @author Yancharuk Alexander <alex at itvault at info>
19
 */
20
class RedirectAdapter extends ViewAdapterAbstract
21
{
22
	/**
23
	 * Driver initialization
24
	 */
25 3
	public function __construct()
26
	{
27 3
		$this->setDriver($this);
28
	}
29
30
	/**
31
	 * Output method
32
	 *
33
	 * Controller must return array like: ['URL']
34
	 *
35
	 * @param string $path Path to template
36
	 */
37 1
	public function show($path)
38
	{
39 1
		if (empty($this->variables)) {
40 1
			return;
41
		}
42
43 1
		$path = current($this->variables);
44
45 1
		header("Location: $path", true, 302);
46
	}
47
48
	/**
49
	 * Output View into buffer and save it in variable
50
	 *
51
	 * @param string $path Path to template
52
	 *
53
	 * @return string View content
54
	 */
55 1
	public function get($path)
56
	{
57 1
		return '';
58
	}
59
60
	/**
61
	 * Check template cache status
62
	 *
63
	 * @param string $tpl Template file
64
	 *
65
	 * @return bool Cache status
66
	 */
67 1
	public function isCached($tpl)
68
	{
69 1
		return false;
70
	}
71
}
72