| 1 | <?php |
||
| 11 | |||
| 12 | |||
| 13 | /** |
||
| 14 | * Represents a request processer that delegates pre and post request handling to nested request filters |
||
| 15 | * |
||
| 16 | * @package framework |
||
| 17 | * @subpackage control |
||
| 18 | */ |
||
| 19 | class RequestProcessor implements RequestFilter { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * List of currently assigned request filters |
||
| 23 | * |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | private $filters = array(); |
||
| 27 | |||
| 28 | public function __construct($filters = array()) { |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Assign a list of request filters |
||
| 34 | * |
||
| 35 | * @param array $filters |
||
| 36 | */ |
||
| 37 | public function setFilters($filters) { |
||
| 40 | |||
| 41 | View Code Duplication | public function preRequest(HTTPRequest $request, Session $session, DataModel $model) { |
|
| 49 | |||
| 50 | View Code Duplication | public function postRequest(HTTPRequest $request, HTTPResponse $response, DataModel $model) { |
|
| 51 | foreach ($this->filters as $filter) { |
||
| 59 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.