TContent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
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
    protected string $contentKey = '';
16
17 17
    public function setContentKey(string $contentKey): self
18
    {
19 17
        $this->contentKey = $contentKey;
20 17
        return $this;
21
    }
22
23
    /**
24
     * @throws MapperException
25
     * @return string
26
     */
27 10
    public function getContentKey(): string
28
    {
29 10
        $this->checkContentKey();
30 9
        return $this->contentKey;
31
    }
32
33
    /**
34
     * @throws MapperException
35
     */
36 10
    protected function checkContentKey(): void
37
    {
38 10
        if (empty($this->contentKey)) {
39 1
            throw new MapperException('Cannot manipulate content without data key - content itself!');
40
        }
41
    }
42
}
43