Passed
Push — master ( c85748...2fd0ab )
by Petr
08:11
created

TContent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A checkContentKey() 0 4 2
A getContentKey() 0 4 1
A setContentKey() 0 4 1
1
<?php
2
3
namespace kalanis\kw_mapper\Mappers\Shared;
4
5
6
use kalanis\kw_mapper\MapperException;
7
8
9
/**
10
 * Trait TContent
11
 * @package kalanis\kw_mapper\Mappers\Shared
12
 */
13
trait TContent
14
{
15
    /** @var string */
16
    protected $contentKey = '';
17
18 17
    public function setContentKey(string $contentKey): self
19
    {
20 17
        $this->contentKey = $contentKey;
21 17
        return $this;
22
    }
23
24
    /**
25
     * @throws MapperException
26
     * @return string
27
     */
28 10
    public function getContentKey(): string
29
    {
30 10
        $this->checkContentKey();
31 9
        return $this->contentKey;
32
    }
33
34
    /**
35
     * @throws MapperException
36
     */
37 10
    protected function checkContentKey(): void
38
    {
39 10
        if (empty($this->contentKey)) {
40 1
            throw new MapperException('Cannot manipulate content without data key - content itself!');
41
        }
42
    }
43
}
44