WordRequest::mask()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Dictionary\Features\WordsFinder\Request;
6
7
use Symfony\Component\HttpFoundation\RequestStack;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\RequestStack was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
final class WordRequest
10
{
11
    private const LIMIT = 100;
12
13
    private RequestStack $requestStack;
14
15
    public function __construct(RequestStack $requestStack)
16
    {
17
        $this->requestStack = $requestStack;
18
    }
19
20
    public function mask(): string
21
    {
22
        RequestAssert::missingRequest($request = $this->requestStack->getCurrentRequest());
23
24
        $query = $request->query;
25
26
        return (string) $query->get('mask', '');
27
    }
28
29
    public function language(): string
30
    {
31
        RequestAssert::missingRequest($request = $this->requestStack->getCurrentRequest());
32
33
        return (string) $request->get('language', 'en');
34
    }
35
36
    public function limit(): int
37
    {
38
        RequestAssert::missingRequest($request = $this->requestStack->getCurrentRequest());
39
40
        $headers = $request->headers;
41
42
        return (int) $headers->get('X-LIMIT', (string) self::LIMIT);
43
    }
44
}
45