Controller::getFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Core\Lib;
4
5
use Core\Application;
6
use Core\Config;
7
use Core\View;
8
use Illuminate\Http\Request as Request;
9
use Illuminate\Http\Response;
10
11
class Controller extends Application
12
{
13
    protected $blade;
14
15
    public $framework , $request , $response , $params;
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
16
17
    /**
18
     * Controller constructor.
19
     */
20
    public function __construct()
21
    {
22
        parent::__construct();
23
24
        $this->framework = (object) Config::get('framework');
25
        $this->request = (new Request());
26
        $this->response = (new Response());
27
    }
28
29
    /**
30
     * @return View
31
     */
32
    public function _404()
33
    {
34
        return $this->view('error.404');
35
    }
36
37
    /**
38
     * @param      $view
39
     * @param null $params
40
     *
41
     * @return View
42
     */
43
    public function view($view, $params = null)
44
    {
45
        $render = View::getInstance();
46
        $render->render($view, $params);
47
48
        return $render;
49
    }
50
51
    /**
52
     * Determine if the uploaded data contains a file.
53
     *
54
     * @param string $key
55
     * @param null   $default
56
     *
57
     * @return bool
58
     */
59
    public function getFile($key = null, $default = null)
60
    {
61
        return $this->request->capture()->file($key, $default);
62
    }
63
64
    /**
65
     * Determine if the uploaded data contains a file.
66
     *
67
     * @param string $key
68
     *
69
     * @return bool
70
     */
71
    public function hasFile($key)
72
    {
73
        if ($this->request->capture()->hasFile($key)) {
74
            return $this->request->capture()->file($key);
75
        } else {
76
            return $this->request->capture()->hasFile($key);
77
        }
78
    }
79
80
    /**
81
     * Checks if the request method is of specified type.
82
     *
83
     * @param string $method Uppercase request method (GET, POST etc).
84
     *
85
     * @return bool
86
     */
87
    public function isMethod($method)
88
    {
89
        return $this->request->capture()->isMethod($method);
90
    }
91
92
    /**
93
     * Get the request method.
94
     *
95
     * @return string
96
     */
97
    public function method()
98
    {
99
        return $this->request->capture()->method();
100
    }
101
102
    /**
103
     * Retrieve an input item from the request.
104
     *
105
     * @param string            $key
106
     * @param string|array|null $default
107
     *
108
     * @return string|array
109
     */
110
    public function input($key = null, $default = null)
111
    {
112
        return $this->request->capture()->input($key, $default);
113
    }
114
115
    /**
116
     * Determine if the request contains a given input item key.
117
     *
118
     * @param $string
119
     *
120
     * @return bool
121
     *
122
     * @internal param array|string $key
123
     */
124
    public function exists($string)
125
    {
126
        return $this->request->capture()->has($string);
127
    }
128
129
    /**
130
     * Get all of the input and files for the request.
131
     *
132
     * @return array
133
     */
134
    public function all()
135
    {
136
        return $this->request->all();
137
    }
138
139
    /**
140
     * Get the JSON payload for the request.
141
     *
142
     * @param string $key
143
     * @param mixed  $default
144
     *
145
     * @return mixed
146
     */
147
    public function json($key = null, $default = null)
148
    {
149
        return $this->request->json($key, $default);
150
    }
151
152
    /**
153
     * Determine if the request is the result of an AJAX call.
154
     *
155
     * @return bool
156
     */
157
    public function ajax()
158
    {
159
        return $this->request->json();
160
    }
161
}
162