Failed Conditions
Branch refactor/kernels (fbf61a)
by Atanas
01:47
created

src/functions.php (6 issues)

1
<?php
2
/**
3
 * @package   WPEmerge
4
 * @author    Atanas Angelov <[email protected]>
5
 * @copyright 2018 Atanas Angelov
6
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7
 * @link      https://wpemerge.com/
8
 */
9
10
use WPEmerge\Facades\Response;
11
use WPEmerge\Facades\View;
12
13
if ( ! function_exists( 'app_response' ) ) {
14
	/**
15
	 * @codeCoverageIgnore
16
	 * @see    \WPEmerge\Responses\ResponseService::response()
17
	 * @return \Psr\Http\Message\ResponseInterface
18
	 */
19
	function app_response() {
20
		return call_user_func_array( [Response::class, 'response'], func_get_args() );
21
	}
22
}
23
24
if ( ! function_exists( 'app_output' ) ) {
25
	/**
26
	 * @codeCoverageIgnore
27
	 * @see    \WPEmerge\Responses\ResponseService::output()
28
	 * @param  string                              $output
29
	 * @return \Psr\Http\Message\ResponseInterface
30
	 */
31
	function app_output( $output ) {
1 ignored issue
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
32
		return call_user_func_array( [Response::class, 'output'], func_get_args() );
33
	}
34
}
35
36
if ( ! function_exists( 'app_json' ) ) {
37
	/**
38
	 * @codeCoverageIgnore
39
	 * @see    \WPEmerge\Responses\ResponseService::json()
40
	 * @param  mixed                               $data
41
	 * @return \Psr\Http\Message\ResponseInterface
42
	 */
43
	function app_json( $data ) {
1 ignored issue
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
		return call_user_func_array( [Response::class, 'json'], func_get_args() );
45
	}
46
}
47
48
if ( ! function_exists( 'app_redirect' ) ) {
49
	/**
50
	 * @codeCoverageIgnore
51
	 * @see    \WPEmerge\Responses\ResponseService::redirect()
52
	 * @return \WPEmerge\Responses\RedirectResponse
53
	 */
54
	function app_redirect() {
1 ignored issue
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
55
		return call_user_func_array( [Response::class, 'redirect'], func_get_args() );
56
	}
57
}
58
59
if ( ! function_exists( 'app_view' ) ) {
60
	/**
61
	 * @codeCoverageIgnore
62
	 * @see    \WPEmerge\Responses\ResponseService::view()
63
	 * @param  string|array<string>         $views
64
	 * @return \WPEmerge\View\ViewInterface
65
	 */
66
	function app_view( $views ) {
1 ignored issue
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
67
		return call_user_func_array( [Response::class, 'view'], func_get_args() );
68
	}
69
}
70
71
if ( ! function_exists( 'app_error' ) ) {
72
	/**
73
	 * @codeCoverageIgnore
74
	 * @see    \WPEmerge\Responses\ResponseService::error()
75
	 * @param  integer                             $status
76
	 * @return \Psr\Http\Message\ResponseInterface
77
	 */
78
	function app_error( $status ) {
1 ignored issue
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
79
		return call_user_func_array( [Response::class, 'error'], func_get_args() );
80
	}
81
}
82
83
if ( ! function_exists( 'app_render' ) ) {
84
	/**
85
	 * @codeCoverageIgnore
86
	 * @see    \WPEmerge\View\ViewService::make()
87
	 * @see    \WPEmerge\View\ViewInterface::toString()
88
	 * @param  string|array<string> $views
89
	 * @param  array<string, mixed> $context
90
	 * @return void
91
	 */
92
	function app_render( $views, $context = [] ) {
1 ignored issue
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
93
		$view = app_view( $views )->with( $context );
94
		View::triggerPartialHooks( $view->getName() );
95
		echo $view->toString();
96
	}
97
}
98
99
if ( ! function_exists( 'app_layout_content' ) ) {
100
	/**
101
	 * @codeCoverageIgnore
102
	 * @see    \WPEmerge\View\PhpView::getLayoutContent()
103
	 * @return void
104
	 */
105
	function app_layout_content() {
106
		echo \WPEmerge\View\PhpView::getLayoutContent();
107
	}
108
}
109
110
if ( ! function_exists( 'app_run' ) ) {
111
	/**
112
	 * @codeCoverageIgnore
113
	 * @see    \WPEmerge\Kernels\HttpKernel::run()
114
	 * @param  \WPEmerge\Requests\RequestInterface $request
115
	 * @param  array<string>                       $middleware
116
	 * @param  string|\Closure                     $handler
117
	 * @param  array                               $arguments
118
	 * @return \Psr\Http\Message\ResponseInterface
119
	 */
120
	function app_run( \WPEmerge\Requests\RequestInterface $request, $middleware, $handler, $arguments = [] ) {
121
		$kernel = \WPEmerge\Facades\Application::resolve( WPEMERGE_WORDPRESS_HTTP_KERNEL_KEY );
122
		return call_user_func_array( [$kernel, 'run'], func_get_args() );
123
	}
124
}
125