for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace vipnytt\XRobotsTagParser;
final class Rebuild
{
private $directiveArray;
/**
* Constructor
*
* @param string $directives
*/
public function __construct($directives)
$this->directiveArray = $directives;
$this->parse();
}
* parse
* @return void
private function parse()
$past = [];
while ($past !== $this->directiveArray) {
$past = $this->directiveArray;
$this->all();
$this->noIndex();
$this->none();
$this->unavailableAfter();
* Directive all
private function all()
if (!isset($this->directiveArray['all'])) {
return;
unset($this->directiveArray['all']);
* Directive noindex
private function noIndex()
if (!isset($this->directiveArray['noindex'])) {
$this->directiveArray['noarchive'] = true;
* Directive none
private function none()
if (!isset($this->directiveArray['none'])) {
$this->directiveArray['noindex'] = true;
$this->directiveArray['nofollow'] = true;
* Directive unavailable_after
private function unavailableAfter()
if (!isset($this->directiveArray['unavailable_after'])) {
$dateTime = date_create_from_format(DATE_RFC850, $this->directiveArray['unavailable_after']);
if ($dateTime !== false && time() >= $dateTime->getTimestamp()) {
* Result
* @return array
public function getResult()
return $this->directiveArray;