Passed
Push — master ( df08cc...276b2d )
by Peter
02:35
created

PageViewed   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 65
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setIsAllowed() 0 3 1
A getPage() 0 3 1
A getUserGroupIdentifiers() 0 3 1
A setPage() 0 6 1
A __construct() 0 5 1
A isAllowed() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Website\Events;
6
7
use AbterPhp\Website\Domain\Entities\Page as Entity;
8
9
class PageViewed
10
{
11
    /** @var Entity */
12
    private $page;
13
14
    /** @var bool */
15
    private $isAllowed = false;
16
17
    /** @var string[] */
18
    private $userGroupIdentifiers = [];
19
20
    /**
21
     * PageViewed constructor.
22
     *
23
     * @param Entity $page
24
     * @param array   $userGroupIdentifiers
25
     */
26
    public function __construct(Entity $page, array $userGroupIdentifiers)
27
    {
28
        $this->setPage($page);
29
30
        $this->userGroupIdentifiers = $userGroupIdentifiers;
31
    }
32
33
    /**
34
     * @return Entity
35
     */
36
    public function getPage(): Entity
37
    {
38
        return $this->page;
39
    }
40
41
    /**
42
     * @return IView
0 ignored issues
show
Bug introduced by
The type AbterPhp\Website\Events\IView 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...
43
     */
44
    public function setPage(Entity $page): PageViewed
45
    {
46
        $this->page      = $page;
47
        $this->isAllowed = !$page->isDraft();
48
49
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type AbterPhp\Website\Events\PageViewed which is incompatible with the documented return type AbterPhp\Website\Events\IView.
Loading history...
50
    }
51
52
    /**
53
     * @return bool
54
     */
55
    public function isAllowed(): bool
56
    {
57
        return $this->isAllowed;
58
    }
59
60
    /**
61
     * @param bool $isAllowed
62
     */
63
    public function setIsAllowed(bool $isAllowed): void
64
    {
65
        $this->isAllowed = $isAllowed;
66
    }
67
68
    /**
69
     * @return string[]
70
     */
71
    public function getUserGroupIdentifiers(): array
72
    {
73
        return $this->userGroupIdentifiers;
74
    }
75
}
76