| 1 |
<?php |
| 2 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 3 |
namespace Yoast\WP\SEO\AI\Content_Planner\Domain; |
| 4 |
|
| 5 |
/** |
| 6 |
* Value object for a content outline section. |
| 7 |
*/ |
| 8 |
class Section { |
| 9 |
|
| 10 |
/** |
| 11 |
* The subheading text. |
| 12 |
* |
| 13 |
* @var string|null |
| 14 |
*/ |
| 15 |
private $subheading_text; |
| 16 |
|
| 17 |
/** |
| 18 |
* The content notes. |
| 19 |
* |
| 20 |
* @var array<string> |
| 21 |
*/ |
| 22 |
private $content_notes; |
| 23 |
|
| 24 |
/** |
| 25 |
* The constructor. |
| 26 |
* |
| 27 |
* @param array<string> $content_notes The content notes. |
| 28 |
* @param string|null $subheading_text The subheading text. |
| 29 |
*/ |
| 30 |
public function __construct( array $content_notes, ?string $subheading_text ) { |
| 31 |
$this->subheading_text = $subheading_text; |
| 32 |
$this->content_notes = $content_notes; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Returns the subheading text. |
| 37 |
* |
| 38 |
* @return string|null The subheading text. |
| 39 |
*/ |
| 40 |
public function get_subheading_text(): ?string { |
| 41 |
return $this->subheading_text; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Returns the content notes. |
| 46 |
* |
| 47 |
* @return array<string> The content notes. |
| 48 |
*/ |
| 49 |
public function get_content_notes(): array { |
| 50 |
return $this->content_notes; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Returns this object in array format. |
| 55 |
* |
| 56 |
* @return array<string, string|array<string>|null> The section as an array. |
| 57 |
*/ |
| 58 |
public function to_array(): array { |
| 59 |
return [ |
| 60 |
'subheading_text' => $this->subheading_text, |
| 61 |
'content_notes' => $this->content_notes, |
| 62 |
]; |
| 63 |
} |
| 64 |
} |
| 65 |
|