Post   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 41
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A __construct() 0 20 5
1
<?php
2
3
namespace Leonidas\Library\System\Model\Post;
4
5
use Leonidas\Contracts\System\Model\Author\AuthorInterface;
6
use Leonidas\Contracts\System\Model\Category\CategoryCollectionInterface;
7
use Leonidas\Contracts\System\Model\Comment\CommentCollectionInterface;
8
use Leonidas\Contracts\System\Model\Post\PostInterface;
9
use Leonidas\Contracts\System\Model\Tag\TagCollectionInterface;
10
use Leonidas\Contracts\Util\AutoInvokerInterface;
11
use Leonidas\Library\System\Model\Abstracts\AllAccessGrantedTrait;
12
use Leonidas\Library\System\Model\Abstracts\Post\FilterablePostModelTrait;
13
use Leonidas\Library\System\Model\Abstracts\Post\MimePostModelTrait;
14
use Leonidas\Library\System\Model\Abstracts\Post\MutableAuthoredPostModelTrait;
15
use Leonidas\Library\System\Model\Abstracts\Post\MutableCommentablePostModelTrait;
16
use Leonidas\Library\System\Model\Abstracts\Post\MutableContentPostModelTrait;
17
use Leonidas\Library\System\Model\Abstracts\Post\MutableDatablePostModelTrait;
18
use Leonidas\Library\System\Model\Abstracts\Post\MutablePingablePostModelTrait;
19
use Leonidas\Library\System\Model\Abstracts\Post\MutablePostModelTrait;
20
use Leonidas\Library\System\Model\Abstracts\Post\PolymorphicPostModelTrait;
21
use Leonidas\Library\System\Model\Abstracts\Post\RestrictablePostModelTrait;
22
use Leonidas\Library\System\Model\Abstracts\Post\ValidatesPostTypeTrait;
23
use Leonidas\Library\System\Model\Post\Abstracts\MutablePostTrait;
24
use WP_Post;
25
26
class Post implements PostInterface
27
{
28
    use AllAccessGrantedTrait;
29
    use FilterablePostModelTrait;
0 ignored issues
show
Bug introduced by
The trait Leonidas\Library\System\...ilterablePostModelTrait requires the property $filter which is not provided by Leonidas\Library\System\Model\Post\Post.
Loading history...
30
    use MimePostModelTrait;
31
    use MutableAuthoredPostModelTrait;
0 ignored issues
show
Bug introduced by
The trait Leonidas\Library\System\...eAuthoredPostModelTrait requires the property $post_author which is not provided by Leonidas\Library\System\Model\Post\Post.
Loading history...
32
    use MutableCommentablePostModelTrait;
33
    use MutableContentPostModelTrait;
34
    use MutableDatablePostModelTrait;
35
    use MutablePingablePostModelTrait;
36
    use MutablePostModelTrait;
0 ignored issues
show
introduced by
The trait Leonidas\Library\System\...t\MutablePostModelTrait requires some properties which are not provided by Leonidas\Library\System\Model\Post\Post: $ID, $post_type
Loading history...
37
    use MutablePostTrait;
38
    use PolymorphicPostModelTrait;
39
    use RestrictablePostModelTrait;
40
    use ValidatesPostTypeTrait;
0 ignored issues
show
Bug introduced by
The trait Leonidas\Library\System\...\ValidatesPostTypeTrait requires the property $post_type which is not provided by Leonidas\Library\System\Model\Post\Post.
Loading history...
41
42
    public function __construct(
43
        WP_Post $post,
44
        AutoInvokerInterface $autoInvoker,
45
        ?AuthorInterface $author = null,
46
        ?TagCollectionInterface $tags = null,
47
        ?CategoryCollectionInterface $categories = null,
48
        ?CommentCollectionInterface $comments = null
49
    ) {
50
        $this->assertPostType($post, 'post');
51
52
        $this->post = $post;
53
        $this->autoInvoker = $autoInvoker;
54
55
        $author && $this->author = $author;
56
        $tags && $this->tags = $tags;
57
        $categories && $this->categories = $categories;
58
        $comments && $this->comments = $comments;
59
60
        $this->getAccessProvider = new PostTemplateTags($this, $post);
61
        $this->setAccessProvider = new PostSetAccessProvider($this);
62
    }
63
64
    public function __toString(): string
65
    {
66
        return $this->getAccessProvider->get('content');
67
    }
68
}
69