| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 |
namespace Yoast\WP\SEO\Dashboard\Domain\Score_Results; |
| 5 |
|
| 6 |
/** |
| 7 |
* This class describes a score result. |
| 8 |
*/ |
| 9 |
class Score_Result { |
| 10 |
|
| 11 |
/** |
| 12 |
* The list of the current scores of the score result. |
| 13 |
* |
| 14 |
* @var Current_Scores_List |
| 15 |
*/ |
| 16 |
private $current_scores_list; |
| 17 |
|
| 18 |
/** |
| 19 |
* The time the query took to get the score results. |
| 20 |
* |
| 21 |
* @var float |
| 22 |
*/ |
| 23 |
private $query_time; |
| 24 |
|
| 25 |
/** |
| 26 |
* Whether cache was used to get the score results. |
| 27 |
* |
| 28 |
* @var bool |
| 29 |
*/ |
| 30 |
private $is_cached_used; |
| 31 |
|
| 32 |
/** |
| 33 |
* The constructor. |
| 34 |
* |
| 35 |
* @param Current_Scores_List $current_scores_list The list of the current scores of the score result. |
| 36 |
* @param float $query_time The time the query took to get the score results. |
| 37 |
* @param bool $is_cached_used Whether cache was used to get the score results. |
| 38 |
*/ |
| 39 |
public function __construct( Current_Scores_List $current_scores_list, float $query_time, bool $is_cached_used ) { |
| 40 |
$this->current_scores_list = $current_scores_list; |
| 41 |
$this->query_time = $query_time; |
| 42 |
$this->is_cached_used = $is_cached_used; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Return this object represented by a key value array. |
| 47 |
* |
| 48 |
* @return array<string, array<array<string, string|int|array<string, string>>>|float|bool> Returns the name and if the feature is enabled. |
| 49 |
*/ |
| 50 |
public function to_array(): array { |
| 51 |
return [ |
| 52 |
'scores' => $this->current_scores_list->to_array(), |
| 53 |
'queryTime' => $this->query_time, |
| 54 |
'cacheUsed' => $this->is_cached_used, |
| 55 |
]; |
| 56 |
} |
| 57 |
} |
| 58 |
|