Skip to content

Commit 57c01bb

Browse files
committed
Merge pull request #8 from getherbert/use-illuminate-request
move to illuminate's request instead of our own http implementation
2 parents 7c17294 + 7464b2a commit 57c01bb

3 files changed

Lines changed: 10 additions & 140 deletions

File tree

Herbert/Framework/Http.php

Lines changed: 4 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,12 @@
11
<?php namespace Herbert\Framework;
22

3+
use Illuminate\Http\Request;
4+
35
/**
46
* @see http://getherbert.com
57
*/
6-
class Http {
7-
8-
/**
9-
* @var array
10-
*/
11-
protected static $methods = [
12-
'GET',
13-
'POST',
14-
'PUT',
15-
'PATCH',
16-
'DELETE'
17-
];
18-
19-
/**
20-
* @var string
21-
*/
22-
protected $method;
23-
24-
/**
25-
* @var array
26-
*/
27-
protected $bag;
28-
29-
/**
30-
* Builds up the bag and sets the method.
31-
*
32-
* @param array $bag
33-
*/
34-
public function __construct($bag = null)
35-
{
36-
$this->bag = $bag ?: $this->collectBag();
37-
$this->method = $_SERVER['REQUEST_METHOD'];
38-
39-
if (isset($_POST['_method']) && in_array(strtoupper($_POST['_method']), static::$methods))
40-
{
41-
$this->method = strtoupper($_POST['_method']);
42-
}
43-
}
44-
45-
/**
46-
* Gets the HTTP method.
47-
*
48-
* @return mixed
49-
*/
50-
public function method()
51-
{
52-
return $this->method;
53-
}
54-
55-
/**
56-
* Checks if a key exists.
57-
*
58-
* @param $key
59-
* @return bool
60-
*/
61-
public function has($key)
62-
{
63-
return isset($this->bag[$key]);
64-
}
65-
66-
/**
67-
* Get all the keys and values.
68-
*
69-
* @return array
70-
*/
71-
public function all()
72-
{
73-
return array_merge($this->bag, []);
74-
}
75-
76-
/**
77-
* Gets a key's value.
78-
*
79-
* @param $key
80-
* @param mixed $default
81-
* @return mixed
82-
*/
83-
public function get($key, $default = null)
84-
{
85-
if (!$this->has($key))
86-
{
87-
return $default;
88-
}
89-
90-
return $this->bag[$key];
91-
}
92-
93-
/**
94-
* Sets a key's value.
95-
*
96-
* @param $key
97-
* @param $value
98-
* @return void
99-
*/
100-
public function set($key, $value)
101-
{
102-
$this->bag[$key] = $value;
103-
}
104-
105-
/**
106-
* Merges two bags.
107-
*
108-
* @param array $bag
109-
*/
110-
public function put($bag = [])
111-
{
112-
$this->bag = array_merge($this->bag, $bag);
113-
}
114-
115-
/**
116-
* Forgets a key.
117-
*
118-
* @param $key
119-
* @return mixed
120-
*/
121-
public function forget($key)
122-
{
123-
if (!$this->has($key))
124-
{
125-
return null;
126-
}
127-
128-
$value = $this->get($key);
129-
unset($this->bag[$key]);
130-
131-
return $value;
132-
}
8+
class Http extends Request {
1339

134-
/**
135-
* Collects the current bag.
136-
*
137-
* @return mixed
138-
*/
139-
protected function collectBag()
140-
{
141-
return $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET;
142-
}
10+
//
14311

14412
}

Herbert/Framework/Providers/HerbertServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function register()
2626

2727
$this->app->instance(
2828
'http',
29-
$this->app->make('Herbert\Framework\Http', ['app' => $this->app])
29+
\Herbert\Framework\Http::capture()
3030
);
3131

3232
$this->app->alias(

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"description": "Herbert",
44
"license": "MIT",
55
"require": {
6-
"twig/twig": "1.16.*",
7-
"illuminate/database": "5.1.*",
8-
"vierbergenlars/php-semver": "~3.0"
6+
"twig/twig": "~1.16",
7+
"illuminate/database": "~5.1",
8+
"vierbergenlars/php-semver": "~3.0",
9+
"symfony/var-dumper": "~3.0",
10+
"illuminate/http": "~5.1"
911
},
1012
"autoload": {
1113
"psr-4": {

0 commit comments

Comments
 (0)