Passed
Push — master ( 66adbf...3d5320 )
by Iman
04:29
created

Responder::jsonp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 5
dl 0
loc 3
rs 10
1
<?php
2
3
namespace ImanGhafoori\Terminator;
4
5
use Illuminate\Contracts\Routing\ResponseFactory;
6
7
class Responder implements ResponseFactory
8
{
9
    /**
10
     * Return a new response from the application.
11
     *
12
     * @param  string  $content
13
     * @param  int  $status
14
     * @param  array  $headers
15
     * @return \Illuminate\Http\Response
16
     */
17
    public function make($content = '', $status = 200, array $headers = [])
18
    {
19
        respondWith(response()->make($content, $status, $headers));
20
    }
21
22
    /**
23
     * Create a new "no content" response.
24
     *
25
     * @param  int  $status
26
     * @param  array  $headers
27
     * @return \Illuminate\Http\Response
28
     */
29
    public function noContent($status = 204, array $headers = [])
30
    {
31
        respondWith(response()->noContent($status, $headers));
32
    }
33
34
    /**
35
     * Return a new view response from the application.
36
     *
37
     * @param  string  $view
38
     * @param  array  $data
39
     * @param  int  $status
40
     * @param  array  $headers
41
     * @return \Illuminate\Http\Response
42
     */
43
    public function view($view, $data = [], $status = 200, array $headers = [])
44
    {
45
        respondWith(response()->view($view, $data, $status, $headers ));
46
    }
47
48
    /**
49
     * Return a new JSON response from the application.
50
     *
51
     * @param  string|array  $data
52
     * @param  int  $status
53
     * @param  array  $headers
54
     * @param  int  $options
55
     * @return \Illuminate\Http\JsonResponse
56
     */
57
    public function json($data = [], $status = 200, array $headers = [], $options = 0)
58
    {
59
        respondWith(response()->json($data, $status, $headers, $options));
60
    }
61
    /**
62
     * Return a new JSONP response from the application.
63
     *
64
     * @param  string  $callback
65
     * @param  string|array  $data
66
     * @param  int  $status
67
     * @param  array  $headers
68
     * @param  int  $options
69
     * @return \Illuminate\Http\JsonResponse
70
     */
71
    public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0)
72
    {
73
        respondWith(response()->jsonp($callback, $data, $status, $headers, $options));
74
    }
75
76
    /**
77
     * Return a new streamed response from the application.
78
     *
79
     * @param  \Closure  $callback
80
     * @param  int  $status
81
     * @param  array  $headers
82
     * @return \Symfony\Component\HttpFoundation\StreamedResponse
83
     */
84
    public function stream($callback, $status = 200, array $headers = [])
85
    {
86
        respondWith(response()->stream($callback, $status, $headers));
87
    }
88
89
    /**
90
     * Return a new streamed response as a file download from the application.
91
     *
92
     * @param  \Closure  $callback
93
     * @param  string|null  $name
94
     * @param  array  $headers
95
     * @param  string|null  $disposition
96
     * @return \Symfony\Component\HttpFoundation\StreamedResponse
97
     */
98
    public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment')
99
    {
100
        respondWith(response()->streamDownload($callback, $name, $headers, $disposition ));
101
    }
102
103
    /**
104
     * Create a new file download response.
105
     *
106
     * @param  \SplFileInfo|string  $file
107
     * @param  string|null  $name
108
     * @param  array  $headers
109
     * @param  string|null  $disposition
110
     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
111
     */
112
    public function download($file, $name = null, array $headers = [], $disposition = 'attachment')
113
    {
114
        respondWith(response()->download($file, $name, $headers, $disposition ));
115
    }
116
117
    /**
118
     * Return the raw contents of a binary file.
119
     *
120
     * @param  \SplFileInfo|string  $file
121
     * @param  array  $headers
122
     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
123
     */
124
    public function file($file, array $headers = [])
125
    {
126
        respondWith(response()->file($file, $headers));
127
    }
128
129
    /**
130
     * Create a new redirect response to the given path.
131
     *
132
     * @param  string  $path
133
     * @param  int  $status
134
     * @param  array  $headers
135
     * @param  bool|null  $secure
136
     * @return \Illuminate\Http\RedirectResponse
137
     */
138
    public function redirectTo($path, $status = 302, $headers = [], $secure = null)
139
    {
140
        respondWith(response()->redirectTo($path, $status, $headers, $secure));
141
    }
142
143
    /**
144
     * Create a new redirect response to a named route.
145
     *
146
     * @param  string  $route
147
     * @param  array  $parameters
148
     * @param  int  $status
149
     * @param  array  $headers
150
     * @return \Illuminate\Http\RedirectResponse
151
     */
152
    public function redirectToRoute($route, $parameters = [], $status = 302, $headers = [])
153
    {
154
        respondWith(response()->redirectToRoute($route, $parameters, $status, $headers));
155
    }
156
157
    /**
158
     * Create a new redirect response to a controller action.
159
     *
160
     * @param  string  $action
161
     * @param  array  $parameters
162
     * @param  int  $status
163
     * @param  array  $headers
164
     * @return \Illuminate\Http\RedirectResponse
165
     */
166
    public function redirectToAction($action, $parameters = [], $status = 302, $headers = [])
167
    {
168
        respondWith(response()->redirectToAction($action, $parameters, $status, $headers ));
169
    }
170
171
    /**
172
     * Create a new redirect response, while putting the current URL in the session.
173
     *
174
     * @param  string  $path
175
     * @param  int  $status
176
     * @param  array  $headers
177
     * @param  bool|null  $secure
178
     * @return \Illuminate\Http\RedirectResponse
179
     */
180
    public function redirectGuest($path, $status = 302, $headers = [], $secure = null)
181
    {
182
        respondWith(response()->redirectGuest($path, $status, $headers, $secure));
183
    }
184
185
    /**
186
     * Create a new redirect response to the previously intended location.
187
     *
188
     * @param  string  $default
189
     * @param  int  $status
190
     * @param  array  $headers
191
     * @param  bool|null  $secure
192
     * @return \Illuminate\Http\RedirectResponse
193
     */
194
    public function redirectToIntended($default = '/', $status = 302, $headers = [], $secure = null)
195
    {
196
        respondWith(response()->redirectToIntended($default, $status, $headers, $secure ));
197
    }
198
}