Passed
Push — master ( 86e7b7...820e92 )
by Atanas
02:10
created

functions.php ➔ wpm_partial()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use WPEmerge\Response;
4
use WPEmerge\Helpers\Mixed;
5
6
if ( ! function_exists( 'wpm_response' ) ) {
7
	/**
8
	 * @codeCoverageIgnore
9
	 * @see Response::response()
10
	 * @return \Psr\Http\Message\ResponseInterface
11
	 */
12
	function wpm_response() {
13
		return Response::response();
14
	}
15
}
16
17
if ( ! function_exists( 'wpm_output' ) ) {
18
	/**
19
	 * @codeCoverageIgnore
20
	 * @see Response::output()
21
	 * @return \Psr\Http\Message\ResponseInterface
22
	 */
23
	function wpm_output( $output ) {
24
		return Response::output( wpm_response(), $output );
25
	}
26
}
27
28
if ( ! function_exists( 'wpm_view' ) ) {
29
	/**
30
	 * @codeCoverageIgnore
31
	 * @see Response::view()
32
	 * @return \Psr\Http\Message\ResponseInterface
33
	 */
34
	function wpm_view( $views, $context = array() ) {
35
		return Response::view( wpm_response(), $views, $context );
36
	}
37
}
38
39
if ( ! function_exists( 'wpm_json' ) ) {
40
	/**
41
	 * @codeCoverageIgnore
42
	 * @see Response::json()
43
	 * @return \Psr\Http\Message\ResponseInterface
44
	 */
45
	function wpm_json( $data ) {
46
		return Response::json( wpm_response(), $data );
47
	}
48
}
49
50
if ( ! function_exists( 'wpm_redirect' ) ) {
51
	/**
52
	 * @codeCoverageIgnore
53
	 * @see Response::redirect()
54
	 * @return \Psr\Http\Message\ResponseInterface
55
	 */
56
	function wpm_redirect( $url, $status = 302 ) {
57
		return Response::redirect( wpm_response(), $url, $status );
58
	}
59
}
60
61
if ( ! function_exists( 'wpm_reload' ) ) {
62
	/**
63
	 * @codeCoverageIgnore
64
	 * @see Response::reload()
65
	 * @return \Psr\Http\Message\ResponseInterface
66
	 */
67
	function wpm_reload( $request, $status = 302 ) {
68
		return Response::reload( wpm_response(), $request, $status );
69
	}
70
}
71
72
if ( ! function_exists( 'wpm_error' ) ) {
73
	/**
74
	 * @codeCoverageIgnore
75
	 * @see Response::error()
76
	 * @return \Psr\Http\Message\ResponseInterface
77
	 */
78
	function wpm_error( $code ) {
79
		return Response::error( wpm_response(), $code );
80
	}
81
}
82
83
if ( ! function_exists( 'wpm_partial' ) ) {
84
	/**
85
	 * @codeCoverageIgnore
86
	 * @see WPEmerge\View\Php::render()
87
	 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
88
	 */
89
	function wpm_partial( $views, $context = [] ) {
90
		$views = Mixed::toArray( $views );
91
		$engine = WPEmerge::resolve( WPEMERGE_VIEW_ENGINE_PHP_KEY );
92
		echo $engine->render( $views, $context );
93
	}
94
}
95