| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Services\Health_Check; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\Should_Index_Links_Conditional; |
| 6 |
|
| 7 |
/** |
| 8 |
* Passes when the links table is accessible. |
| 9 |
*/ |
| 10 |
class Links_Table_Check extends Health_Check { |
| 11 |
|
| 12 |
/** |
| 13 |
* Runs the health check. |
| 14 |
* |
| 15 |
* @var Links_Table_Runner |
| 16 |
*/ |
| 17 |
private $runner; |
| 18 |
|
| 19 |
/** |
| 20 |
* Generates WordPress-friendly health check results. |
| 21 |
* |
| 22 |
* @var Links_Table_Reports |
| 23 |
*/ |
| 24 |
private $reports; |
| 25 |
|
| 26 |
/** |
| 27 |
* The conditional that checks if the links table should be indexed. |
| 28 |
* |
| 29 |
* @var Should_Index_Links_Conditional |
| 30 |
*/ |
| 31 |
private $should_index_links_conditional; |
| 32 |
|
| 33 |
/** |
| 34 |
* Constructor. |
| 35 |
* |
| 36 |
* @param Links_Table_Runner $runner The object that implements the actual health check. |
| 37 |
* @param Links_Table_Reports $reports The object that generates WordPress-friendly results. |
| 38 |
* @param Should_Index_Links_Conditional $should_index_links_conditional The conditional that checks if the links table should be indexed. |
| 39 |
*/ |
| 40 |
public function __construct( |
| 41 |
Links_Table_Runner $runner, |
| 42 |
Links_Table_Reports $reports, |
| 43 |
Should_Index_Links_Conditional $should_index_links_conditional |
| 44 |
) { |
| 45 |
$this->runner = $runner; |
| 46 |
$this->reports = $reports; |
| 47 |
$this->should_index_links_conditional = $should_index_links_conditional; |
| 48 |
|
| 49 |
$this->reports->set_test_identifier( $this->get_test_identifier() ); |
| 50 |
$this->set_runner( $this->runner ); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Returns the WordPress-friendly health check result. |
| 55 |
* |
| 56 |
* @return string[] The WordPress-friendly health check result. |
| 57 |
*/ |
| 58 |
protected function get_result() { |
| 59 |
if ( $this->runner->is_successful() ) { |
| 60 |
return $this->reports->get_success_result(); |
| 61 |
} |
| 62 |
|
| 63 |
return $this->reports->get_links_table_not_accessible_result(); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Returns whether the health check should be excluded from the results. |
| 68 |
* |
| 69 |
* @return bool false, because it's not excluded. |
| 70 |
*/ |
| 71 |
public function is_excluded() { |
| 72 |
return ! $this->should_index_links_conditional->is_met(); |
| 73 |
} |
| 74 |
} |
| 75 |
|