| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Services\Health_Check; |
| 4 |
|
| 5 |
/** |
| 6 |
* Paasses when permalinks are set to contain the post name. |
| 7 |
*/ |
| 8 |
class Postname_Permalink_Check extends Health_Check { |
| 9 |
|
| 10 |
/** |
| 11 |
* Runs the health check. |
| 12 |
* |
| 13 |
* @var Postname_Permalink_Runner |
| 14 |
*/ |
| 15 |
private $runner; |
| 16 |
|
| 17 |
/** |
| 18 |
* Generates WordPress-friendly health check results. |
| 19 |
* |
| 20 |
* @var Postname_Permalink_Reports |
| 21 |
*/ |
| 22 |
private $reports; |
| 23 |
|
| 24 |
/** |
| 25 |
* Constructor. |
| 26 |
* |
| 27 |
* @param Postname_Permalink_Runner $runner The object that implements the actual health check. |
| 28 |
* @param Postname_Permalink_Reports $reports The object that generates WordPress-friendly results. |
| 29 |
*/ |
| 30 |
public function __construct( Postname_Permalink_Runner $runner, Postname_Permalink_Reports $reports ) { |
| 31 |
$this->runner = $runner; |
| 32 |
$this->reports = $reports; |
| 33 |
$this->reports->set_test_identifier( $this->get_test_identifier() ); |
| 34 |
|
| 35 |
$this->set_runner( $this->runner ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Returns the WordPress-friendly health check result. |
| 40 |
* |
| 41 |
* @return string[] The WordPress-friendly health check result. |
| 42 |
*/ |
| 43 |
protected function get_result() { |
| 44 |
if ( $this->runner->is_successful() ) { |
| 45 |
return $this->reports->get_success_result(); |
| 46 |
} |
| 47 |
|
| 48 |
return $this->reports->get_has_no_postname_in_permalink_result(); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Returns whether the health check should be excluded from the results. |
| 53 |
* |
| 54 |
* @return bool false, because it's not excluded. |
| 55 |
*/ |
| 56 |
public function is_excluded() { |
| 57 |
return false; |
| 58 |
} |
| 59 |
} |
| 60 |
|