for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Equip\Auth\Credentials;
use Psr\Http\Message\ServerRequestInterface;
use Equip\Auth\Credentials;
/**
* Extracts credentials from top-level properties of a request body.
*/
class BodyExtractor implements ExtractorInterface
{
* @var string
private $identifier;
private $password;
* @param string $identifier
* Name of the property that identifies the user
* @param string $password
* Name of the property that contains the user password
public function __construct($identifier = 'username', $password = 'password')
$this->identifier = $identifier;
$this->password = $password;
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.
}
* @inheritDoc
public function getCredentials(ServerRequestInterface $request)
$body = $request->getParsedBody();
if (empty($body[$this->identifier]) || empty($body[$this->password])) {
return null;
return new Credentials($body[$this->identifier], $body[$this->password]);
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.