Completed
Pull Request — master (#42)
by Frederik
01:52
created

SectionItem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 41
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A __toString() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\MessageData\Item;
5
6
use Genkgo\Mail\Protocol\Imap\MessageData\ItemInterface;
7
use Genkgo\Mail\Protocol\Imap\MessageData\SectionList;
8
9
/**
10
 * Class SectionItem
11
 * @package Genkgo\Mail\Protocol\Imap\MessageData\GenericItem
12
 */
13
final class SectionItem implements ItemInterface
14
{
15
    /**
16
     * @var ItemInterface
17
     */
18
    private $nameItem;
19
    /**
20
     * @var SectionList
21
     */
22
    private $sectionList;
23
24
    /**
25
     * @param ItemInterface $nameItem
26
     * @param SectionList $sectionList
27
     */
28 7
    public function __construct(ItemInterface $nameItem, SectionList $sectionList)
29
    {
30 7
        $this->nameItem = $nameItem;
31 7
        $this->sectionList = $sectionList;
32 7
    }
33
34
    /**
35
     * @return string
36
     */
37 7
    public function getName(): string
38
    {
39 7
        return $this->nameItem->getName();
40
    }
41
42
    /**
43
     * @return string
44
     */
45 5
    public function __toString(): string
46
    {
47 5
        return sprintf(
48 5
            '%s%s',
49 5
            $this->getName(),
50 5
            (string)$this->sectionList
51
        );
52
    }
53
}