for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace vipnytt\RobotsTxtParser\Parser\Directives;
use vipnytt\RobotsTxtParser\Parser\RobotsTxtInterface;
use vipnytt\RobotsTxtParser\Parser\Toolbox;
/**
* Class RequestRate
*
* @package vipnytt\RobotsTxtParser\Parser\Directives
*/
class RequestRate implements DirectiveInterface, RobotsTxtInterface
{
use Toolbox;
* Directive
const DIRECTIVE = self::DIRECTIVE_VISIT_TIME;
* RequestRate array
* @var array
protected $array = [];
* RequestRate constructor.
public function __construct()
}
* Add
* @param string $line
* @return bool
public function add($line)
$array = preg_split('/\s+/', $line, 2);
$result = [
'rate' => $this->draftParseRate($array[0]),
];
if ($result['rate'] === false) {
return false;
} elseif (
!empty($array[1]) &&
($times = $this->draftParseTime($array[1])) !== false
) {
$result = array_merge($result, $times);
$this->array[] = $result;
return true;
* Export
* @return array
public function export()
return empty($this->array) ? [] : [self::DIRECTIVE => $this->array];