for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Comodojo\Dispatcher\Request;
use \Comodojo\Foundation\Base\ParametersTrait;
/**
* @package Comodojo Dispatcher
* @author Marco Giovinazzi <[email protected]>
* @author Marco Castiello <[email protected]>
* @license MIT
*
* LICENSE:
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
class Post {
use ParametersTrait;
protected $raw_parameters;
public function __construct() {
$this->parameters = self::getParameters();
$this->raw_parameters = self::getRawParameters();
}
public function getRaw() {
return $this->raw_parameters;
private static function getParameters() {
switch ($_SERVER['REQUEST_METHOD']) {
case 'POST':
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
switch ($expr) { case "A": doSomething(); //right break; case "B": doSomethingElse(); //wrong break;
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.
$parameters = $_POST;
break;
case 'PUT':
case 'DELETE':
parse_str(file_get_contents('php://input'), $parameters);
default:
According to the PSR-2, the body of a default statement must start on the line immediately following the statement.
switch ($expr) { default: doSomething(); //right break; } switch ($expr) { default: doSomething(); //wrong break; }
$parameters = array();
return $parameters;
private static function getRawParameters() {
return file_get_contents('php://input');
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.