Test Failed
Push — master ( fdb79d...2e4512 )
by Chris
19:35
created

PostConstrainer::requestMeetsCriteria()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Leonidas\Library\System\Post\Constraints;
4
5
use Leonidas\Contracts\Http\ConstrainerInterface;
6
use Leonidas\Traits\ExpectsPostTrait;
7
use Psr\Http\Message\ServerRequestInterface;
8
9
class PostConstrainer implements ConstrainerInterface
10
{
11
    use ExpectsPostTrait;
0 ignored issues
show
Bug introduced by
The trait Leonidas\Traits\ExpectsPostTrait requires the property $ID which is not provided by Leonidas\Library\System\...traints\PostConstrainer.
Loading history...
12
13
    /**
14
     * @var int[]
15
     */
16
    protected $posts = [];
17
18
    /**
19
     *
20
     */
21
    public function __construct(int ...$posts)
22
    {
23
        $this->posts = $posts;
24
    }
25
26
    /**
27
     * Get the value of posts
28
     *
29
     * @return int[]
30
     */
31
    public function getPosts(): array
32
    {
33
        return $this->posts;
34
    }
35
36
    /**
37
     *
38
     */
39
    public function requestMeetsCriteria(ServerRequestInterface $request): bool
40
    {
41
        return in_array($this->getPostId($request), $this->posts);
42
    }
43
}
44