| Conditions | 1 |
| Paths | 1 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 7 | public function build(RobotsTxt $robot): string |
||
| 8 | { |
||
| 9 | $robotsTxt = ['Sitemap: ' . $robot->sitemap()]; |
||
| 10 | $rules = $robot->ruleSetCollection() |
||
| 11 | ->map(function (RulesSet $rule) { |
||
| 12 | return array_merge( |
||
| 13 | [ |
||
| 14 | '', |
||
| 15 | 'User-Agent: ' . $rule->userAgent(), |
||
| 16 | ], |
||
| 17 | array_map(function (string $string) { |
||
| 18 | return "Allow: $string"; |
||
| 19 | }, $rule->allowRules()), |
||
| 20 | array_map(function (string $string) { |
||
| 21 | return "Disallow: $string"; |
||
| 22 | }, $rule->disallowRules()) |
||
| 23 | ); |
||
| 24 | }) |
||
| 25 | ->flatten() |
||
| 26 | ->toArray(); |
||
| 27 | |||
| 28 | return implode(PHP_EOL, array_merge($robotsTxt, $rules)); |
||
| 29 | } |
||
| 31 |