Completed
Pull Request — master (#2)
by Jan-Petter
02:43
created

SubDirectiveHandler   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 148
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 9
c 3
b 0
f 0
lcom 0
cbo 6
dl 0
loc 148
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A allow() 0 4 1
A cacheDelay() 0 4 1
A comment() 0 4 1
A crawlDelay() 0 4 1
A disallow() 0 4 1
A requestRate() 0 4 1
A robotVersion() 0 4 1
A visitTime() 0 4 1
A __construct() 0 11 1
1
<?php
2
namespace vipnytt\RobotsTxtParser\Parser\Directives;
3
4
use vipnytt\RobotsTxtParser\RobotsTxtInterface;
5
6
/**
7
 * Class SubDirectiveHandler
8
 *
9
 * @package vipnytt\RobotsTxtParser\Parser\Directives
10
 */
11
class SubDirectiveHandler implements RobotsTxtInterface
12
{
13
    /**
14
     * Allow
15
     * @var DisAllowParser
16
     */
17
    private $allow;
18
19
    /**
20
     * Cache-delay
21
     * @var DelayParser
22
     */
23
    private $cacheDelay;
24
25
    /**
26
     * Comment
27
     * @var CommentParser
28
     */
29
    private $comment;
30
31
    /**
32
     * Crawl-delay
33
     * @var DelayParser
34
     */
35
    private $crawlDelay;
36
37
    /**
38
     * Disallow
39
     * @var DisAllowParser
40
     */
41
    private $disallow;
42
43
    /**
44
     * Request-rate
45
     * @var RequestRateParser
46
     */
47
    private $requestRate;
48
49
    /**
50
     * Robot-version
51
     * @var RobotVersionParser
52
     */
53
    private $robotVersion;
54
55
    /**
56
     * Visit-time
57
     * @var VisitTimeParser
58
     */
59
    private $visitTime;
60
61
    /**
62
     * SubDirectiveHandler constructor.
63
     *
64
     * @param string $base
65
     * @param string $userAgent
66
     */
67
    public function __construct($base, $userAgent)
68
    {
69
        $this->allow = new DisAllowParser($base, self::DIRECTIVE_ALLOW);
70
        $this->cacheDelay = new DelayParser($base, $userAgent, self::DIRECTIVE_CACHE_DELAY);
71
        $this->comment = new CommentParser($base, $userAgent);
72
        $this->crawlDelay = new DelayParser($base, $userAgent, self::DIRECTIVE_CRAWL_DELAY);
73
        $this->disallow = new DisAllowParser($base, self::DIRECTIVE_DISALLOW);
74
        $this->requestRate = new RequestRateParser($base, $userAgent);
75
        $this->robotVersion = new RobotVersionParser();
76
        $this->visitTime = new VisitTimeParser();
77
    }
78
79
    /**
80
     * Allow
81
     *
82
     * @return DisAllowParser
83
     */
84
    public function allow()
85
    {
86
        return $this->allow;
87
    }
88
89
    /**
90
     * Cache-delay
91
     *
92
     * @return DelayParser
93
     */
94
    public function cacheDelay()
95
    {
96
        return $this->cacheDelay;
97
    }
98
99
    /**
100
     * Comment
101
     *
102
     * @return CommentParser
103
     */
104
    public function comment()
105
    {
106
        return $this->comment;
107
    }
108
109
    /**
110
     * Crawl-delay
111
     *
112
     * @return DelayParser
113
     */
114
    public function crawlDelay()
115
    {
116
        return $this->crawlDelay;
117
    }
118
119
    /**
120
     * Disallow
121
     *
122
     * @return DisAllowParser
123
     */
124
    public function disallow()
125
    {
126
        return $this->disallow;
127
    }
128
129
    /**
130
     * Request-rate
131
     *
132
     * @return RequestRateParser
133
     */
134
    public function requestRate()
135
    {
136
        return $this->requestRate;
137
    }
138
139
    /**
140
     * Robot-version
141
     *
142
     * @return RobotVersionParser
143
     */
144
    public function robotVersion()
145
    {
146
        return $this->robotVersion;
147
    }
148
149
    /**
150
     * Visit-time
151
     *
152
     * @return VisitTimeParser
153
     */
154
    public function visitTime()
155
    {
156
        return $this->visitTime;
157
    }
158
}
159