Test Failed
Push — feature-laravel-5.4 ( 2b4b90...5bfdc4 )
by Kirill
03:52
created

ProcessedBody::getLinks()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of laravel.su package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types = 1);
9
10
namespace App\Services\ContentRenderer\Anchors;
11
12
/**
13
 * Class ProcessedBody
14
 */
15
class ProcessedBody
16
{
17
    /**
18
     * @var string
19
     */
20
    private $body;
21
22
    /**
23
     * @var array|AnchorLink[]
24
     */
25
    private $links = [];
26
27
    /**
28
     * ProcessedBody constructor.
29
     *
30
     * @param string $body
31
     * @param array  $links
32
     */
33
    public function __construct(string $body, array $links = [])
34
    {
35
        $this->body = $body;
36
        $this->links = $links;
37
    }
38
39
    /**
40
     * @param AnchorLink $link
41
     * @return $this|ProcessedBody
42
     */
43
    public function addAnchorLink(AnchorLink $link): ProcessedBody
44
    {
45
        $this->links[] = $link;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getContent(): string
54
    {
55
        return $this->body;
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public function getLinks(): array
62
    {
63
        $result = [];
64
65
        foreach ($this->links as $link) {
66
            $result[] = $link->toArray();
67
        }
68
69
        return $result;
70
    }
71
}
72