Code Duplication    Length = 16-16 lines in 6 locations

src/ServerRequest/HasAttribute.php 1 location

@@ 8-23 (lines=16) @@
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr7Unitesting\Utils\ValueConstraintTrait;
7
8
class HasAttribute extends AbstractConstraint
9
{
10
    use ValueConstraintTrait;
11
12
    public function toString()
13
    {
14
        return sprintf('has the attribute "%s"', $this->expected);
15
    }
16
17
    protected function runMatches(ServerRequestInterface $request)
18
    {
19
        $attributes = $request->getAttributes();
20
21
        return isset($attributes[$this->expected]);
22
    }
23
}
24

src/ServerRequest/HasCookieParam.php 1 location

@@ 8-23 (lines=16) @@
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr7Unitesting\Utils\ValueConstraintTrait;
7
8
class HasCookieParam extends AbstractConstraint
9
{
10
    use ValueConstraintTrait;
11
12
    public function toString()
13
    {
14
        return sprintf('has the cookies parameter "%s"', $this->expected);
15
    }
16
17
    protected function runMatches(ServerRequestInterface $request)
18
    {
19
        $cookies = $request->getCookieParams();
20
21
        return isset($cookies[$this->expected]);
22
    }
23
}
24

src/ServerRequest/HasParsedBody.php 1 location

@@ 8-23 (lines=16) @@
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr7Unitesting\Utils\ValueConstraintTrait;
7
8
class HasParsedBody extends AbstractConstraint
9
{
10
    use ValueConstraintTrait;
11
12
    public function toString()
13
    {
14
        return sprintf('has the key "%s" in the parsed body', $this->expected);
15
    }
16
17
    protected function runMatches(ServerRequestInterface $request)
18
    {
19
        $body = $request->getParsedBody();
20
21
        return isset($body[$this->expected]);
22
    }
23
}
24

src/ServerRequest/HasQueryParam.php 1 location

@@ 8-23 (lines=16) @@
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr7Unitesting\Utils\ValueConstraintTrait;
7
8
class HasQueryParam extends AbstractConstraint
9
{
10
    use ValueConstraintTrait;
11
12
    public function toString()
13
    {
14
        return sprintf('has the query parameter "%s"', $this->expected);
15
    }
16
17
    protected function runMatches(ServerRequestInterface $request)
18
    {
19
        $query = $request->getQueryParams();
20
21
        return isset($query[$this->expected]);
22
    }
23
}
24

src/ServerRequest/HasServerParam.php 1 location

@@ 8-23 (lines=16) @@
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr7Unitesting\Utils\ValueConstraintTrait;
7
8
class HasServerParam extends AbstractConstraint
9
{
10
    use ValueConstraintTrait;
11
12
    public function toString()
13
    {
14
        return sprintf('has the server parameter "%s"', $this->expected);
15
    }
16
17
    protected function runMatches(ServerRequestInterface $request)
18
    {
19
        $server = $request->getServerParams();
20
21
        return isset($server[$this->expected]);
22
    }
23
}
24

src/ServerRequest/HasUploadedFile.php 1 location

@@ 8-23 (lines=16) @@
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr7Unitesting\Utils\ValueConstraintTrait;
7
8
class HasUploadedFile extends AbstractConstraint
9
{
10
    use ValueConstraintTrait;
11
12
    public function toString()
13
    {
14
        return sprintf('has the upload file "%s"', $this->expected);
15
    }
16
17
    protected function runMatches(ServerRequestInterface $request)
18
    {
19
        $files = $request->getUploadedFiles();
20
21
        return isset($files[$this->expected]);
22
    }
23
}
24