| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Values\Robots; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Directive |
| 7 |
*/ |
| 8 |
class User_Agent { |
| 9 |
|
| 10 |
/** |
| 11 |
* The user agent identifier. |
| 12 |
* |
| 13 |
* @var string |
| 14 |
*/ |
| 15 |
private $user_agent; |
| 16 |
|
| 17 |
/** |
| 18 |
* All directives that are allowed for this user agent. |
| 19 |
* |
| 20 |
* @var Directive |
| 21 |
*/ |
| 22 |
private $allow_directive; |
| 23 |
|
| 24 |
/** |
| 25 |
* All directives that are disallowed for this user agent. |
| 26 |
* |
| 27 |
* @var Directive |
| 28 |
*/ |
| 29 |
private $disallow_directive; |
| 30 |
|
| 31 |
/** |
| 32 |
* Constructor of the user agent value object. |
| 33 |
* |
| 34 |
* @param string $user_agent The user agent identifier. |
| 35 |
*/ |
| 36 |
public function __construct( $user_agent ) { |
| 37 |
$this->user_agent = $user_agent; |
| 38 |
$this->allow_directive = new Directive(); |
| 39 |
$this->disallow_directive = new Directive(); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Gets the user agent identifier. |
| 44 |
* |
| 45 |
* @return string |
| 46 |
*/ |
| 47 |
public function get_user_agent() { |
| 48 |
return $this->user_agent; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Adds a path to the directive object. |
| 53 |
* |
| 54 |
* @param string $path The path to add to the disallow directive. |
| 55 |
* |
| 56 |
* @return void |
| 57 |
*/ |
| 58 |
public function add_disallow_directive( $path ) { |
| 59 |
$this->disallow_directive->add_path( $path ); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Adds a path to the directive object. |
| 64 |
* |
| 65 |
* @param string $path The path to add to the allow directive. |
| 66 |
* |
| 67 |
* @return void |
| 68 |
*/ |
| 69 |
public function add_allow_directive( $path ) { |
| 70 |
$this->allow_directive->add_path( $path ); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Gets all disallow paths for this user agent. |
| 75 |
* |
| 76 |
* @return array |
| 77 |
*/ |
| 78 |
public function get_disallow_paths() { |
| 79 |
return $this->disallow_directive->get_paths(); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Gets all sallow paths for this user agent. |
| 84 |
* |
| 85 |
* @return array |
| 86 |
*/ |
| 87 |
public function get_allow_paths() { |
| 88 |
return $this->allow_directive->get_paths(); |
| 89 |
} |
| 90 |
} |
| 91 |
|