| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong |
| 4 |
namespace Yoast\WP\SEO\Llms_Txt\Application\Health_Check; |
| 5 |
|
| 6 |
use Yoast\WP\SEO\Llms_Txt\Application\File\Commands\Populate_File_Command_Handler; |
| 7 |
use Yoast\WP\SEO\Services\Health_Check\Runner_Interface; |
| 8 |
|
| 9 |
/** |
| 10 |
* Runs the File_Generation health check. |
| 11 |
*/ |
| 12 |
class File_Runner implements Runner_Interface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Is set to non-empty string when the llms.txt file failed to (re-)generate. |
| 16 |
* |
| 17 |
* @var bool |
| 18 |
*/ |
| 19 |
private $generation_failure_reason = ''; |
| 20 |
|
| 21 |
/** |
| 22 |
* Runs the health check. |
| 23 |
* |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public function run() { |
| 27 |
$this->generation_failure_reason = \get_option( Populate_File_Command_Handler::GENERATION_FAILURE_OPTION, '' ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Returns true if there is no generation failure reason. |
| 32 |
* |
| 33 |
* @return bool The boolean indicating if the health check was succesful. |
| 34 |
*/ |
| 35 |
public function is_successful() { |
| 36 |
return $this->generation_failure_reason === ''; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Returns the generation failure reason. |
| 41 |
* |
| 42 |
* @return string The boolean indicating if the health check was succesful. |
| 43 |
*/ |
| 44 |
public function get_generation_failure_reason(): string { |
| 45 |
return $this->generation_failure_reason; |
| 46 |
} |
| 47 |
} |
| 48 |
|