/home/techb158/ileadtechnology.com/vendor/spatie/robots-txt/src
Edit: /home/techb158/ileadtechnology.com/vendor/spatie/robots-txt/src/RobotsHeaders.php (2676B)
robotHeadersProperties = $this->parseHeaders($headers);
}
public function mayIndex(string $userAgent = '*'): bool
{
return ! $this->noindex($userAgent);
}
public function mayFollow(string $userAgent = '*'): bool
{
return ! $this->nofollow($userAgent);
}
public function noindex(string $userAgent = '*'): bool
{
return
$this->robotHeadersProperties[$userAgent]['noindex']
?? $this->robotHeadersProperties['*']['noindex']
?? false;
}
public function nofollow(string $userAgent = '*'): bool
{
return
$this->robotHeadersProperties[$userAgent]['nofollow']
?? $this->robotHeadersProperties['*']['nofollow']
?? false;
}
protected function parseHeaders(array $headers): array
{
$robotHeaders = $this->filterRobotHeaders($headers);
return array_reduce($robotHeaders, function (array $parsedHeaders, $header) {
$header = $this->normalizeHeaders($header);
$headerParts = explode(':', $header);
$userAgent = count($headerParts) === 3
? trim($headerParts[1])
: '*';
$options = end($headerParts);
$parsedHeaders[$userAgent] = [
'noindex' => strpos(strtolower($options), 'noindex') !== false,
'nofollow' => strpos(strtolower($options), 'nofollow') !== false,
];
return $parsedHeaders;
}, []);
}
protected function filterRobotHeaders(array $headers): array
{
return array_filter($headers, function ($header) use ($headers) {
$headerContent = $this->normalizeHeaders($headers[$header] ?? []);
return strpos(strtolower($header), 'x-robots-tag') === 0
|| strpos(strtolower($headerContent), 'x-robots-tag') === 0;
}, ARRAY_FILTER_USE_KEY);
}
protected function normalizeHeaders($headers): string
{
return implode(',', (array) $headers);
}
}