Passed
Push — master ( c44d00...13b3c2 )
by David
53s
created

HardCodedTargetOrigins::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
4
namespace TheCodingMachine\Middlewares\OriginFetchers;
5
6
use Psr\Http\Message\ServerRequestInterface;
7
use TheCodingMachine\Middlewares\CsrfHeaderCheckMiddlewareException;
8
9
/**
10
 * A set of hard coded target origins.
11
 * To be used if your application is behind a proxy (thus preventing the use of "HostHeader" class.
12
 */
13
class HardCodedTargetOrigins implements TargetOriginInterface
14
{
15
    /**
16
     * @var \string[]
17
     */
18
    private $origins;
19
20
    /**
21
     * @param \string[] ...$origins A set of domain names for YOUR application.
22
     */
23
    public function __construct(string ...$origins)
24
    {
25
        $this->origins = $origins;
0 ignored issues
show
Documentation Bug introduced by
It seems like $origins of type array<integer,array<integer,object<string>>> is incompatible with the declared type array<integer,object<string>> of property $origins.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
26
    }
27
28
    /**
29
     * Returns an array of domain names for your application.
30
     * If the "source" origin matches one of these origins, the request is valid.
31
     *
32
     * @return string[]
33
     * @throws \TheCodingMachine\Middlewares\CsrfHeaderCheckMiddlewareException
34
     */
35
    public function __invoke(ServerRequestInterface $request): array
36
    {
37
        return $this->origins;
38
    }
39
}
40