MutablePostTrait::setCategories()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 0
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