1 | <?php |
||
9 | class RobotsManager |
||
10 | { |
||
11 | /** |
||
12 | * The lines for the robots.txt. |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $lines = []; |
||
17 | |||
18 | /** |
||
19 | * Generate the robots.txt data. |
||
20 | * |
||
21 | * @return string|null |
||
22 | */ |
||
23 | public function generate(): ?string |
||
27 | |||
28 | /** |
||
29 | * Add a Sitemap to the robots.txt. |
||
30 | * |
||
31 | * @param string $sitemap |
||
32 | */ |
||
33 | public function addSitemap(string $sitemap): void |
||
37 | |||
38 | /** |
||
39 | * Add a line to the robots.txt. |
||
40 | * |
||
41 | * @param string $line |
||
42 | */ |
||
43 | protected function addLine(string $line): void |
||
47 | |||
48 | /** |
||
49 | * Add a User-agent to the robots.txt. |
||
50 | * |
||
51 | * @param string $userAgent |
||
52 | */ |
||
53 | public function addUserAgent(string $userAgent): void |
||
57 | |||
58 | /** |
||
59 | * Add a Host to the robots.txt. |
||
60 | * |
||
61 | * @param string $host |
||
62 | */ |
||
63 | public function addHost(string $host): void |
||
67 | |||
68 | /** |
||
69 | * Add a disallow rule to the robots.txt. |
||
70 | * |
||
71 | * @param string|array $directories |
||
72 | */ |
||
73 | public function addDisallow($directories): void |
||
77 | |||
78 | /** |
||
79 | * Add a rule to the robots.txt. |
||
80 | * |
||
81 | * @param string|array $directories |
||
82 | * @param string $rule |
||
83 | */ |
||
84 | protected function addRuleLine($directories, string $rule): void |
||
90 | |||
91 | /** |
||
92 | * Add a allow rule to the robots.txt. |
||
93 | * |
||
94 | * @param string|array $directories |
||
95 | */ |
||
96 | public function addAllow($directories): void |
||
100 | |||
101 | /** |
||
102 | * Add a comment to the robots.txt. |
||
103 | * |
||
104 | * @param string $comment |
||
105 | */ |
||
106 | public function addComment(string $comment): void |
||
110 | |||
111 | /** |
||
112 | * Add a spacer to the robots.txt. |
||
113 | */ |
||
114 | public function addSpacer(): void |
||
118 | |||
119 | /** |
||
120 | * Reset the lines. |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | public function reset(): void |
||
128 | } |
||
129 |