Skip to content

Commit 8fbaa2d

Browse files
committed
lint fixes
1 parent 7b36131 commit 8fbaa2d

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

includes/Services/SiteGenService.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,36 @@
77
use NewfoldLabs\WP\Module\Onboarding\Data\Services\ThemeGeneratorService;
88
use NewfoldLabs\WP\Module\Onboarding\Services\ReduxStateService;
99

10+
/**
11+
* Class SiteGenService
12+
*
13+
* Handles the onboarding SiteGen flow for generating, publishing, and managing AI-generated homepages and related content.
14+
*
15+
* This service is designed to work with the onboarding module's Redux state and integrates with other onboarding services.
16+
*
17+
* @package NewfoldLabs\WP\Module\Onboarding\Services
18+
*/
1019
class SiteGenService {
1120

1221
/**
1322
* The Redux input object.
1423
*
1524
* @var array|null
1625
*/
17-
private ?array $input_data = null;
18-
26+
private $input_data = null;
27+
1928
/**
2029
* The Redux sitegen object.
2130
*
2231
* @var array|null
2332
*/
24-
private ?array $sitegen_data = null;
33+
private $sitegen_data = null;
2534

35+
/**
36+
* SiteGenService constructor.
37+
*
38+
* Initializes the service by loading the Redux input and sitegen data from the ReduxStateService.
39+
*/
2640
public function __construct() {
2741
$this->input_data = ReduxStateService::get( 'input' );
2842
$this->sitegen_data = ReduxStateService::get( 'sitegen' );
@@ -34,7 +48,7 @@ public function __construct() {
3448
* @param string $selected_sitegen_homepage The selected sitegen homepage to publish.
3549
* @return int|\WP_Error
3650
*/
37-
public function publish_homepage( string $selected_sitegen_homepage ): int | \WP_Error {
51+
public function publish_homepage( string $selected_sitegen_homepage ): int|\WP_Error {
3852
// Validate we have the selected homepage.
3953
if (
4054
! $this->sitegen_data ||
@@ -98,8 +112,8 @@ public function publish_homepage( string $selected_sitegen_homepage ): int | \WP
98112
* @return string|false The page title, or false if not found.
99113
*/
100114
public function get_sitemap_page_title( string $slug ): string|false {
101-
$prompt = $this->get_prompt();
102-
$locale = $this->get_locale();
115+
$prompt = $this->get_prompt();
116+
$locale = $this->get_locale();
103117
$site_type = $this->get_site_type();
104118
if ( ! $prompt || ! $locale || ! $site_type ) {
105119
return false;
@@ -121,7 +135,7 @@ public function get_sitemap_page_title( string $slug ): string|false {
121135
/**
122136
* Add a page to the site navigation.
123137
*
124-
* @param int $post_id The ID of the page to add to the navigation.
138+
* @param int $post_id The ID of the page to add to the navigation.
125139
* @param string $page_title The title of the page.
126140
* @param string $permalink The permalink of the page.
127141
*/
@@ -183,7 +197,7 @@ public function get_locale(): string {
183197
* of the newly uploaded images.
184198
*
185199
* @param array $image_urls An array of image URLs to upload.
186-
* @param int $post_id The post ID to attach the images to.
200+
* @param int $post_id The post ID to attach the images to.
187201
* @return array|false An array of WordPress attachment URLs on success, false on failure.
188202
* @throws Exception If there is an error during the upload process.
189203
*/
@@ -297,14 +311,14 @@ public static function upload_images_to_wp_media_library( $image_urls, $post_id
297311
* with the new ones.
298312
*
299313
* @param string $content The content containing img tags with image URLs.
300-
* @param int $post_id The post ID to attach the images to.
314+
* @param int $post_id The post ID to attach the images to.
301315
* @return string The updated content with new image URLs.
302316
*/
303317
public static function sideload_images_and_replace_grammar( $content, $post_id ) {
304318
// Extract image URLs from img tags in the content
305319
$image_urls = array();
306320
preg_match_all( '/<img[^>]+src=["\']([^"\']+)["\'][^>]*>/i', $content, $matches );
307-
321+
308322
if ( ! empty( $matches[1] ) ) {
309323
$image_urls = array_unique( $matches[1] );
310324
}

0 commit comments

Comments
 (0)