MutablePostTrait   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 58
ccs 0
cts 24
cp 0
rs 10
c 1
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setTags() 0 5 1
A addTags() 0 5 1
A mergeTags() 0 5 1
A addCategories() 0 5 1
A setExcerpt() 0 5 1
A setStatus() 0 5 1
A setCategories() 0 5 1
A mergeCategories() 0 5 1
1
<?php
2
3
namespace Leonidas\Library\System\Model\Post\Abstracts;
4
5
use Leonidas\Contracts\System\Model\Category\CategoryCollectionInterface;
6
use Leonidas\Contracts\System\Model\Category\CategoryInterface;
7
use Leonidas\Contracts\System\Model\Post\Status\PostStatusInterface;
8
use Leonidas\Contracts\System\Model\Tag\TagCollectionInterface;
9
use Leonidas\Contracts\System\Model\Tag\TagInterface;
10
11
trait MutablePostTrait
12
{
13
    use PostTrait;
14
15
    public function setExcerpt(string $excerpt): self
16
    {
17
        $this->post->post_excerpt = $excerpt;
18
19
        return $this;
20
    }
21
22
    public function setStatus(PostStatusInterface $status): self
23
    {
24
        $this->post->post_status = $status->getName();
25
26
        return $this;
27
    }
28
29
    public function setCategories(CategoryCollectionInterface $categories): self
30
    {
31
        $this->categories = $categories;
32
33
        return $this;
34
    }
35
36
    public function addCategories(CategoryInterface ...$categories): self
37
    {
38
        $this->getCategories()->collect(...$categories);
39
40
        return $this;
41
    }
42
43
    public function mergeCategories(CategoryCollectionInterface $categories): self
44
    {
45
        $this->getCategories()->collect(...$categories->values());
46
47
        return $this;
48
    }
49
50
    public function setTags(TagCollectionInterface $tags): self
51
    {
52
        $this->tags = $tags;
53
54
        return $this;
55
    }
56
57
    public function addTags(TagInterface ...$tags): self
58
    {
59
        $this->getTags()->collect(...$tags);
60
61
        return $this;
62
    }
63
64
    public function mergeTags(TagCollectionInterface $tags): self
65
    {
66
        $this->getTags()->collect(...$tags->values());
67
68
        return $this;
69
    }
70
}
71