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

PostConstrainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A requestMeetsCriteria() 0 3 1
A __construct() 0 3 1
A getPosts() 0 3 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