for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Equip\Handler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
abstract class ContentHandler
{
/**
* Parses request bodies based on content type.
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
* @return Response
*/
public function __invoke(
ServerRequestInterface $request,
ResponseInterface $response,
callable $next
) {
$mime = strtolower($request->getHeaderLine('Content-Type'));
if ($this->isApplicableMimeType($mime) && !$request->getParsedBody()) {
$body = (string) $request->getBody();
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$parsed = $this->getParsedBody($body);
$request = $request->withParsedBody($parsed);
}
return $next($request, $response);
* Check if the content type is appropriate for handling.
* @param string $mime
* @return boolean
abstract protected function isApplicableMimeType($mime);
* Parse the request body.
* @param string $body
* @return mixed
abstract protected function getParsedBody($body);
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.