Passed
Push — master ( 7ecba7...031f87 )
by Iman
06:58
created

Responder::streamDownload()   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 4
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
    /**
11
     * Return a new response from the application.
12
     *
13
     * @param  string  $content
14
     * @param  int  $status
15
     * @param  array  $headers
16
     * @return \Illuminate\Http\Response
17
     */
18
    public function make($content = '', $status = 200, array $headers = [])
19
    {
20
        respondWith(response()->make($content, $status, $headers));
21
    }
22
23
    /**
24
     * Return a new view response from the application.
25
     *
26
     * @param  string  $view
27
     * @param  array  $data
28
     * @param  int  $status
29
     * @param  array  $headers
30
     * @return \Illuminate\Http\Response
31
     */
32
    public function view($view, $data = [], $status = 200, array $headers = [])
33
    {
34
        respondWith(response()->view($view, $data, $status, $headers ));
35
    }
36
37
    /**
38
     * Return a new JSON response from the application.
39
     *
40
     * @param  string|array  $data
41
     * @param  int  $status
42
     * @param  array  $headers
43
     * @param  int  $options
44
     * @return \Illuminate\Http\JsonResponse
45
     */
46
    public function json($data = [], $status = 200, array $headers = [], $options = 0)
47
    {
48
        respondWith(response()->json($data, $status, $headers, $options));
49
    }
50
    /**
51
     * Return a new JSONP response from the application.
52
     *
53
     * @param  string  $callback
54
     * @param  string|array  $data
55
     * @param  int  $status
56
     * @param  array  $headers
57
     * @param  int  $options
58
     * @return \Illuminate\Http\JsonResponse
59
     */
60
    public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0)
61
    {
62
        respondWith(response()->jsonp($callback, $data, $status, $headers, $options));
63
    }
64
65
    /**
66
     * Return a new streamed response from the application.
67
     *
68
     * @param  \Closure  $callback
69
     * @param  int  $status
70
     * @param  array  $headers
71
     * @return \Symfony\Component\HttpFoundation\StreamedResponse
72
     */
73
    public function stream($callback, $status = 200, array $headers = [])
74
    {
75
        respondWith(response()->stream($callback, $status, $headers));
76
    }
77
78
    /**
79
     * Return a new streamed response as a file download from the application.
80
     *
81
     * @param  \Closure  $callback
82
     * @param  string|null  $name
83
     * @param  array  $headers
84
     * @param  string|null  $disposition
85
     * @return \Symfony\Component\HttpFoundation\StreamedResponse
86
     */
87
    public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment')
88
    {
89
        respondWith(response()->streamDownload($callback, $name, $headers, $disposition ));
90
    }
91
92
    /**
93
     * Create a new file download response.
94
     *
95
     * @param  \SplFileInfo|string  $file
96
     * @param  string|null  $name
97
     * @param  array  $headers
98
     * @param  string|null  $disposition
99
     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
100
     */
101
    public function download($file, $name = null, array $headers = [], $disposition = 'attachment')
102
    {
103
        respondWith(response()->download($file, $name, $headers, $disposition ));
104
    }
105
106
    /**
107
     * Create a new redirect response to the given path.
108
     *
109
     * @param  string  $path
110
     * @param  int  $status
111
     * @param  array  $headers
112
     * @param  bool|null  $secure
113
     * @return \Illuminate\Http\RedirectResponse
114
     */
115
    public function redirectTo($path, $status = 302, $headers = [], $secure = null)
116
    {
117
        respondWith(response()->redirectTo($path, $status, $headers, $secure));
118
    }
119
120
    /**
121
     * Create a new redirect response to a named route.
122
     *
123
     * @param  string  $route
124
     * @param  array  $parameters
125
     * @param  int  $status
126
     * @param  array  $headers
127
     * @return \Illuminate\Http\RedirectResponse
128
     */
129
    public function redirectToRoute($route, $parameters = [], $status = 302, $headers = [])
130
    {
131
        respondWith(response()->redirectToRoute($route, $parameters, $status, $headers));
132
    }
133
134
    /**
135
     * Create a new redirect response to a controller action.
136
     *
137
     * @param  string  $action
138
     * @param  array  $parameters
139
     * @param  int  $status
140
     * @param  array  $headers
141
     * @return \Illuminate\Http\RedirectResponse
142
     */
143
    public function redirectToAction($action, $parameters = [], $status = 302, $headers = [])
144
    {
145
        respondWith(response()->redirectToAction($action, $parameters, $status, $headers ));
146
    }
147
148
    /**
149
     * Create a new redirect response, while putting the current URL in the session.
150
     *
151
     * @param  string  $path
152
     * @param  int  $status
153
     * @param  array  $headers
154
     * @param  bool|null  $secure
155
     * @return \Illuminate\Http\RedirectResponse
156
     */
157
    public function redirectGuest($path, $status = 302, $headers = [], $secure = null)
158
    {
159
        respondWith(response()->redirectGuest($path, $status, $headers, $secure));
160
    }
161
162
    /**
163
     * Create a new redirect response to the previously intended location.
164
     *
165
     * @param  string  $default
166
     * @param  int  $status
167
     * @param  array  $headers
168
     * @param  bool|null  $secure
169
     * @return \Illuminate\Http\RedirectResponse
170
     */
171
    public function redirectToIntended($default = '/', $status = 302, $headers = [], $secure = null)
172
    {
173
        respondWith(response()->redirectToIntended($default, $status, $headers, $secure ));
174
    }
175
}