| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 |
namespace Yoast\WP\SEO\Bulk_Editor\Domain\Posts; |
| 5 |
|
| 6 |
/** |
| 7 |
* This class describes a single content item shown in the bulk editor table. |
| 8 |
*/ |
| 9 |
class Post { |
| 10 |
|
| 11 |
/** |
| 12 |
* The post ID. |
| 13 |
* |
| 14 |
* @var int |
| 15 |
*/ |
| 16 |
private $id; |
| 17 |
|
| 18 |
/** |
| 19 |
* The post title. |
| 20 |
* |
| 21 |
* @var string |
| 22 |
*/ |
| 23 |
private $title; |
| 24 |
|
| 25 |
/** |
| 26 |
* The post status. |
| 27 |
* |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
private $status; |
| 31 |
|
| 32 |
/** |
| 33 |
* The URL to edit the post. |
| 34 |
* |
| 35 |
* @var string |
| 36 |
*/ |
| 37 |
private $edit_link; |
| 38 |
|
| 39 |
/** |
| 40 |
* The focus keyphrase. |
| 41 |
* |
| 42 |
* @var string |
| 43 |
*/ |
| 44 |
private $focus_keyphrase; |
| 45 |
|
| 46 |
/** |
| 47 |
* The SEO title. |
| 48 |
* |
| 49 |
* @var string |
| 50 |
*/ |
| 51 |
private $seo_title; |
| 52 |
|
| 53 |
/** |
| 54 |
* The meta description. |
| 55 |
* |
| 56 |
* @var string |
| 57 |
*/ |
| 58 |
private $meta_description; |
| 59 |
|
| 60 |
/** |
| 61 |
* The social title. |
| 62 |
* |
| 63 |
* @var string |
| 64 |
*/ |
| 65 |
private $social_title; |
| 66 |
|
| 67 |
/** |
| 68 |
* The social description. |
| 69 |
* |
| 70 |
* @var string |
| 71 |
*/ |
| 72 |
private $social_description; |
| 73 |
|
| 74 |
/** |
| 75 |
* Whether the current user may edit this post. |
| 76 |
* |
| 77 |
* @var bool |
| 78 |
*/ |
| 79 |
private $editable; |
| 80 |
|
| 81 |
/** |
| 82 |
* The constructor. |
| 83 |
* |
| 84 |
* @param int $id The post ID. |
| 85 |
* @param string $title The post title. |
| 86 |
* @param string $status The post status. |
| 87 |
* @param string $edit_link The URL to edit the post. |
| 88 |
* @param string $focus_keyphrase The focus keyphrase. |
| 89 |
* @param string $seo_title The SEO title. |
| 90 |
* @param string $meta_description The meta description. |
| 91 |
* @param string $social_title The social title. |
| 92 |
* @param string $social_description The social description. |
| 93 |
* @param bool $editable Whether the current user may edit this post. |
| 94 |
*/ |
| 95 |
public function __construct( |
| 96 |
int $id, |
| 97 |
string $title, |
| 98 |
string $status, |
| 99 |
string $edit_link, |
| 100 |
string $focus_keyphrase, |
| 101 |
string $seo_title, |
| 102 |
string $meta_description, |
| 103 |
string $social_title, |
| 104 |
string $social_description, |
| 105 |
bool $editable |
| 106 |
) { |
| 107 |
$this->id = $id; |
| 108 |
$this->title = $title; |
| 109 |
$this->status = $status; |
| 110 |
$this->edit_link = $edit_link; |
| 111 |
$this->focus_keyphrase = $focus_keyphrase; |
| 112 |
$this->seo_title = $seo_title; |
| 113 |
$this->meta_description = $meta_description; |
| 114 |
$this->social_title = $social_title; |
| 115 |
$this->social_description = $social_description; |
| 116 |
$this->editable = $editable; |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Parses the post to the expected key value representation. |
| 121 |
* |
| 122 |
* @return array<string, int|string|bool> The post presented as the expected key value representation. |
| 123 |
*/ |
| 124 |
public function to_array(): array { |
| 125 |
return [ |
| 126 |
'id' => $this->id, |
| 127 |
'title' => $this->title, |
| 128 |
'status' => $this->status, |
| 129 |
'edit_link' => $this->edit_link, |
| 130 |
'focus_keyphrase' => $this->focus_keyphrase, |
| 131 |
'seo_title' => $this->seo_title, |
| 132 |
'meta_description' => $this->meta_description, |
| 133 |
'social_title' => $this->social_title, |
| 134 |
'social_description' => $this->social_description, |
| 135 |
'editable' => $this->editable, |
| 136 |
]; |
| 137 |
} |
| 138 |
} |
| 139 |
|