Passed
Push — analysis-qBJygA ( 146b42 )
by Nuno
09:11 queued 41s
created

ObjectQueue::getTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Scout Extended.
7
 *
8
 * (c) Algolia Team <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Algolia\ScoutExtended\Splitters\HtmlSplitterComponent;
15
16
final class ObjectQueue
17
{
18
    private $tag;
19
    private $tagContent;
20
21
    /**
22
     * Object constructor.
23
     *
24
     * @param string $tag
25
     * @param string $tagContent
26
     */
27 5
    public function __construct(string $tag, string $tagContent)
28
    {
29 5
        $this->tag = $tag;
30 5
        $this->tagContent = $this->cleanTagContent($tagContent);
31 5
    }
32
33
    /**
34
     * @return string
35
     */
36 5
    public function getTag(): string
37
    {
38 5
        return $this->tag;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 5
    public function getTagContent(): string
45
    {
46 5
        return $this->tagContent;
47
    }
48
49
    /**
50
     * Clean Content from Html tag.
51
     * Remove space at the begin and end, useless space, return.
52
     *
53
     * @param string $tagContent
54
     *
55
     * @return string
56
     */
57 5
    private function cleanTagContent(string $tagContent): string
58
    {
59 5
        return trim(preg_replace('/\s+/', ' ', str_replace('\n', '', $tagContent)));
60
    }
61
}
62