Completed
Push — master ( a6d8dc...680f8e )
by Jan-Petter
03:57
created

RobotVersion::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 7
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
namespace vipnytt\RobotsTxtParser\Parser\Directives;
3
4
use vipnytt\RobotsTxtParser\Parser\RobotsTxtInterface;
5
6
/**
7
 * Class RobotVersion
8
 *
9
 * @package vipnytt\RobotsTxtParser\Parser\Directives
10
 */
11
class RobotVersion implements DirectiveInterface, RobotsTxtInterface
12
{
13
    /**
14
     * Directive
15
     */
16
    const DIRECTIVE = self::DIRECTIVE_ROBOT_VERSION;
17
18
    /**
19
     * RobotVersion value
20
     * @var float|int|string
21
     */
22
    protected $value;
23
24
    /**
25
     * RobotVersion constructor.
26
     */
27
    public function __construct()
28
    {
29
    }
30
31
    /**
32
     * Add
33
     *
34
     * @param float|int|string $line
35
     * @return bool
36
     */
37
    public function add($line)
38
    {
39
        if (!empty($this->value)) {
40
            return false;
41
        }
42
        $this->value = $line;
43
        return true;
44
    }
45
46
    /**
47
     * Export rules
48
     *
49
     * @return float[][]|int[][]|string[][]
50
     */
51
    public function export()
52
    {
53
        return empty($this->value) ? [] : [self::DIRECTIVE => $this->value];
54
    }
55
56
    /**
57
     * Render
58
     *
59
     * @return string[]
60
     */
61 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...
62
    {
63
        if (!empty($this->value)) {
64
            return [self::DIRECTIVE . ': ' . $this->value];
65
        }
66
        return [];
67
    }
68
}
69