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

SectionItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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