Completed
Branch 2.0-dev (131e57)
by Jan-Petter
02:08
created

Comment::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace vipnytt\RobotsTxtParser\Core\Directives;
3
4
use vipnytt\RobotsTxtParser\Core\RobotsTxtInterface;
5
6
/**
7
 * Class Comment
8
 *
9
 * @package vipnytt\RobotsTxtParser\Core\Directives
10
 */
11
class Comment implements DirectiveInterface, RobotsTxtInterface
12
{
13
    /**
14
     * Directive
15
     */
16
    const DIRECTIVE = self::DIRECTIVE_COMMENT;
17
18
    /**
19
     * Comment array
20
     * @var string[]
21
     */
22
    protected $array = [];
23
24
    /**
25
     * Comment constructor.
26
     */
27
    public function __construct()
28
    {
29
    }
30
31
    /**
32
     * Add
33
     *
34
     * @param string $line
35
     * @return bool
36
     */
37
    public function add($line)
38
    {
39
        $this->array[] = $line;
40
        return true;
41
    }
42
43
    /**
44
     * Export rules
45
     *
46
     * @return string[][]
47
     */
48
    public function export()
49
    {
50
        return empty($this->array) ? [] : [self::DIRECTIVE => $this->array];
51
    }
52
53
    /**
54
     * Render
55
     *
56
     * @return string[]
57
     */
58 View Code Duplication
    public function render()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        $result = [];
61
        foreach ($this->array as $value) {
62
            $result[] = self::DIRECTIVE . ':' . $value;
63
        }
64
        return $result;
65
    }
66
}
67