-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marc Scholten
committed
Jul 16, 2016
1 parent
0aa2b16
commit 4e55181
Showing
8 changed files
with
108 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace MPScholten\RequestParser; | ||
|
||
interface RequestParserFactory | ||
{ | ||
/** | ||
* @return RequestParser | ||
*/ | ||
public function createQueryParser(); | ||
|
||
/** | ||
* @return RequestParser | ||
*/ | ||
public function createBodyParser(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace MPScholten\RequestParser\Symfony; | ||
|
||
use MPScholten\RequestParser\RequestParser; | ||
use MPScholten\RequestParser\RequestParserFactory; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class SymfonyRequestParserFactory implements RequestParserFactory | ||
{ | ||
private $request; | ||
private $exceptionFactory; | ||
|
||
public function __construct(Request $request, $exceptionFactory = null) | ||
{ | ||
$this->request = $request; | ||
$this->exceptionFactory = $exceptionFactory; | ||
} | ||
|
||
public function createQueryParser() | ||
{ | ||
$readParameter = function ($name) { | ||
return $this->request->query->get($name, null); | ||
}; | ||
|
||
return new RequestParser($readParameter, $this->exceptionFactory); | ||
} | ||
|
||
public function createBodyParser() | ||
{ | ||
$readParameter = function ($name) { | ||
return $this->request->request->get($name, null); | ||
}; | ||
|
||
return new RequestParser($readParameter, $this->exceptionFactory); | ||
} | ||
} |