Completed
Push — master ( cf0606...512c88 )
by Jan-Petter
04:57
created

VisitTime::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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