Skip to content

Commit

Permalink
CS.
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsoo committed Nov 13, 2023
1 parent 49f252f commit a22a22d
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Yoast\WP\SEO\Indexables\Domain\Exceptions\No_Verification_Action_Left_Exception;
use Yoast\WP\SEO\Indexables\Domain\Exceptions\Verify_Action_Not_Found_Exception;
use Yoast\WP\SEO\Indexables\Infrastructure\Actions\Verify_General_Indexables_Action;
use Yoast\WP\SEO\Indexables\Infrastructure\Actions\Verify_Post_Links_Indexables_Action;
use Yoast\WP\SEO\Indexables\Infrastructure\Actions\Verify_Post_Type_Archives_Indexables_Action;
use Yoast\WP\SEO\Indexables\Infrastructure\Actions\Verify_Term_Indexables_Action;
use Yoast\WP\SEO\Indexables\Infrastructure\Actions\Verify_Term_Links_Indexables_Action;
Expand Down Expand Up @@ -61,10 +60,10 @@ class Verify_Indexable_Action_Factory implements Verify_Indexables_Action_Factor
/**
* The constructor.
*
* @param Verify_Term_Indexables_Action $verify_term_indexables_action The instance.
* @param Verify_General_Indexables_Action $verify_general_indexables_action The instance.
* @param Verify_Term_Indexables_Action $verify_term_indexables_action The instance.
* @param Verify_General_Indexables_Action $verify_general_indexables_action The instance.
* @param Verify_Post_Type_Archives_Indexables_Action $verify_post_type_archives_indexables_action The instance.
* @param Verify_Term_Links_Indexables_Action $verify_term_links_indexables_action The instance.
* @param Verify_Term_Links_Indexables_Action $verify_term_links_indexables_action The instance.
*/
public function __construct(
Verify_Term_Indexables_Action $verify_term_indexables_action,
Expand Down Expand Up @@ -104,7 +103,8 @@ public function get( Current_Verification_Action $verification_action ): Verify_
/**
* Determines the next verification action that needs to be taken.
*
* @param Current_Verification_Action $current_verification_action_object The current verification object to determine the next one for.
* @param Current_Verification_Action $current_verification_action_object The current verification object to
* determine the next one for.
*
* @throws No_Verification_Action_Left_Exception Throws when there are no verification actions left.
* @return Current_Verification_Action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/**
* The Verify_Non_Timestamp_Indexables_Command_Handler class.
*
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
*/
class Verify_Non_Timestamp_Indexables_Command_Handler {
Expand Down Expand Up @@ -49,10 +50,11 @@ class Verify_Non_Timestamp_Indexables_Command_Handler {
/**
* The constructor.
*
* @param Verification_Cron_Schedule_Handler $cron_schedule_handler The cron schedule handler.
* @param Verification_Cron_Batch_Handler $cron_batch_handler The cron batch handler.
* @param Verify_Indexables_Action_Factory_Interface $verify_indexables_action_factory The verify indexables action factory.
* @param Next_Verification_Action_Handler $action_handler The action handler.
* @param Verification_Cron_Schedule_Handler $cron_schedule_handler The cron schedule handler.
* @param Verification_Cron_Batch_Handler $cron_batch_handler The cron batch handler.
* @param Verify_Indexables_Action_Factory_Interface $verify_indexables_action_factory The verify indexables action
* factory.
* @param Next_Verification_Action_Handler $action_handler The action handler.
*/
public function __construct(
Verification_Cron_Schedule_Handler $cron_schedule_handler,
Expand All @@ -77,8 +79,9 @@ public function handle( Verify_Non_Timestamp_Indexables_Command $verify_non_time

try {
$verification_action = $this->verify_indexables_action_factory->get( $verify_non_timestamp_indexables_command->get_current_action() );
}catch ( Verify_Action_Not_Found_Exception $exception ) {
} catch ( Verify_Action_Not_Found_Exception $exception ) {
$this->cron_schedule_handler->unschedule_verify_non_timestamped_indexables_cron();

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Yoast\WP\SEO\Indexables\Application\Commands;

use Yoast\WP\SEO\Indexables\Domain\Abstract_Indexables_Command;
use Yoast\WP\SEO\Indexables\Domain\Batch_Size;
use Yoast\WP\SEO\Indexables\Domain\Current_Verification_Action;

/**
Expand All @@ -21,9 +20,9 @@ class Verify_Non_Timestamp_Indexables_Command extends Abstract_Indexables_Comman
/**
* The constructor.
*
* @param int $last_batch The last batch count.
* @param int $batch_size The batch size.
* @param string $current_action The current verification action.
* @param int $last_batch The last batch count.
* @param int $batch_size The batch size.
* @param string $current_action The current verification action.
*/
public function __construct( int $last_batch, int $batch_size, string $current_action ) {
$this->current_action = new Current_Verification_Action( $current_action );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ class Verify_Post_Indexables_Command_Handler {
/**
* The constructor.
*
* @param Outdated_Post_Indexables_Repository_Interface $outdated_post_indexables_repository The outdated post indexables repository.
* @param Verification_Cron_Schedule_Handler $cron_schedule_handler The cron schedule handler.
* @param Verification_Cron_Batch_Handler $verification_cron_batch_handler The verification cron batch handler.
* @param Indexable_Builder $indexable_builder The indexable builder.
* @param Outdated_Post_Indexables_Repository_Interface $outdated_post_indexables_repository The outdated post
* indexables repository.
* @param Verification_Cron_Schedule_Handler $cron_schedule_handler The cron schedule
* handler.
* @param Verification_Cron_Batch_Handler $verification_cron_batch_handler The verification cron
* batch handler.
* @param Indexable_Builder $indexable_builder The indexable builder.
*/
public function __construct(
Outdated_Post_Indexables_Repository_Interface $outdated_post_indexables_repository,
Expand Down Expand Up @@ -88,7 +91,8 @@ public function handle( Verify_Post_Indexables_Command $verify_post_indexables_c
return;
}

$next_batch = ( $verify_post_indexables_command->get_last_batch_count()->get_last_batch() + $verify_post_indexables_command->get_batch_size()->get_batch_size() );
$next_batch = ( $verify_post_indexables_command->get_last_batch_count()
->get_last_batch() + $verify_post_indexables_command->get_batch_size()->get_batch_size() );
$this->verification_cron_batch_handler->set_current_post_indexables_batch( $next_batch );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Yoast\WP\SEO\Indexables\Domain\Abstract_Indexables_Command;
use Yoast\WP\SEO\Indexables\Domain\Last_Batch_Count;


/**
* The Verify_Post_Indexables_Command class.
*/
Expand Down
1 change: 0 additions & 1 deletion src/indexables/application/cron-verification-gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Yoast\WP\SEO\Indexables\Application;

use Yoast\WP\SEO\Helpers\Indexable_Helper;
use Yoast\WP\SEO\Helpers\Options_Helper;

/**
* The Cron_Verification_Gate class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Yoast\WP\SEO\Indexables\Domain\Exceptions\No_Outdated_Posts_Found_Exception;
use Yoast\WP\SEO\Indexables\Domain\Last_Batch_Count;
use Yoast\WP\SEO\Indexables\Domain\Outdated_Post_Indexables_List;
use Yoast\WP\SEO\Indexables\Domain\Plugin_Deactivated_Timestamp;

interface Outdated_Post_Indexables_Repository_Interface {

Expand All @@ -19,7 +18,5 @@ interface Outdated_Post_Indexables_Repository_Interface {
* @throws No_Outdated_Posts_Found_Exception When there are no outdated posts found.
* @return Outdated_Post_Indexables_List
*/
public function get_outdated_post_indexables(
Last_Batch_Count $count
): Outdated_Post_Indexables_List;
public function get_outdated_post_indexables( Last_Batch_Count $count ): Outdated_Post_Indexables_List;
}
11 changes: 7 additions & 4 deletions src/indexables/application/verification-cron-batch-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct( Options_Helper $options_helper ) {
*
* @return int
*/
public function get_current_post_indexables_batch():int {
public function get_current_post_indexables_batch(): int {
return $this->options_helper->get( 'cron_verify_post_indexables_last_batch', 0 );
}

Expand All @@ -52,19 +52,22 @@ public function set_current_post_indexables_batch( int $batch_count ) {
*
* @return int
*/
public function get_current_non_timestamped_indexables_batch():int {
public function get_current_non_timestamped_indexables_batch(): int {
return $this->options_helper->get( 'cron_verify_non_timestamped_indexables_last_batch', 0 );
}

/**
* Sets the `cron_verify_non_timestamped_indexables_last_batch` option.
*
* @param Last_Batch_Count $last_batch_count The current batch count.
* @param Batch_Size $batch_size The batch size.
* @param Batch_Size $batch_size The batch size.
*
* @return void
*/
public function set_current_non_timestamped_indexables_batch( Last_Batch_Count $last_batch_count, Batch_Size $batch_size ) {
public function set_current_non_timestamped_indexables_batch(
Last_Batch_Count $last_batch_count,
Batch_Size $batch_size
) {
$batch_count = ( $last_batch_count->get_last_batch() + $batch_size->get_batch_size() );
$this->options_helper->set( 'cron_verify_non_timestamped_indexables_last_batch', $batch_count );
}
Expand Down
2 changes: 1 addition & 1 deletion src/indexables/domain/abstract-indexables-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class Abstract_Indexables_Command {
* The constructor.
*
* @param int $batch_size The batch size.
* @param int $last_batch The last batch count.
* @param int $last_batch The last batch count.
*/
public function __construct( int $batch_size, int $last_batch ) {
$this->last_batch_count = new Last_Batch_Count( $last_batch );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ interface Verify_Indexables_Action_Factory_Interface {
* @throws Verify_Action_Not_Found_Exception When the given verification action does not exists.
* @return Verify_Indexables_Action_Interface
*/
public function get( Current_Verification_Action $verification_action ):Verify_Indexables_Action_Interface;
public function get( Current_Verification_Action $verification_action ): Verify_Indexables_Action_Interface;

/**
* Determines the next verification action that needs to be taken.
*
* @param Current_Verification_Action $current_verification_action_object The current verification object to determine the next one for.
* @param Current_Verification_Action $current_verification_action_object The current verification object to
* determine the next one for.
*
* @throws No_Verification_Action_Left_Exception Throws when there are no verification actions left.
* @return Current_Verification_Action
*/
public function determine_next_verify_action( Current_Verification_Action $current_verification_action_object ):Current_Verification_Action;
public function determine_next_verify_action( Current_Verification_Action $current_verification_action_object
): Current_Verification_Action;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use Yoast\WP\SEO\Indexables\Domain\Batch_Size;
use Yoast\WP\SEO\Indexables\Domain\Last_Batch_Count;
use Yoast\WP\SEO\Models\Indexable;

/**
* The Verify_Indexables_Action_Interface interface.
Expand All @@ -16,11 +15,11 @@ interface Verify_Indexables_Action_Interface {
* Rebuilds indexables for the given action type.
*
* @param Last_Batch_Count $last_batch_count The last batch count domain object.
* @param Batch_Size $batch_size The batch size domain object.
* @param Batch_Size $batch_size The batch size domain object.
*
* @return bool return false if there are no objects left to re-build.
*/
public function re_build_indexables( Last_Batch_Count $last_batch_count, Batch_Size $batch_size):bool;
public function re_build_indexables( Last_Batch_Count $last_batch_count, Batch_Size $batch_size ): bool;

/**
* Sets the wpdb instance.
Expand All @@ -30,5 +29,5 @@ public function re_build_indexables( Last_Batch_Count $last_batch_count, Batch_S
* @return mixed
* @required
*/
public function set_wpdb( \wpdb $wpdb);
public function set_wpdb( \wpdb $wpdb );
}
3 changes: 1 addition & 2 deletions src/indexables/domain/outdated-post-indexables-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Yoast\WP\SEO\Indexables\Domain;

use WP_Post;
use Yoast\WP\SEO\Models\Indexable;

/**
Expand Down Expand Up @@ -93,7 +92,7 @@ public function valid(): bool {
*
* @return int
*/
public function count():int {
public function count(): int {
return \count( $this->post_indexables_list );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Verify_General_Indexables_Action implements Verify_Indexables_Action_Inter
/**
* The constructor.
*
* @param Indexable_Repository $repository The indexable repository.
* @param Indexable_Repository $repository The indexable repository.
* @param Indexable_Builder $indexable_builder The indexable builder.
*/
public function __construct( Indexable_Repository $repository, Indexable_Builder $indexable_builder ) {
Expand All @@ -50,7 +50,7 @@ public function __construct( Indexable_Repository $repository, Indexable_Builder
* Rebuilds the indexables for the general pages.
*
* @param Last_Batch_Count $last_batch_count The last batch count domain object.
* @param Batch_Size $batch_size The batch size domain object.
* @param Batch_Size $batch_size The batch size domain object.
*
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ class Verify_Post_Type_Archives_Indexables_Action implements Verify_Indexables_A
/**
* The constructor.
*
* @param Post_Type_Helper $post_type_helper The post type helper.
* @param Indexable_Builder $indexable_builder The indexable builder.
* @param Post_Type_Helper $post_type_helper The post type helper.
* @param Indexable_Builder $indexable_builder The indexable builder.
* @param Indexable_Repository $indexable_repository The indexable repository.
*/
public function __construct( Post_Type_Helper $post_type_helper, Indexable_Builder $indexable_builder, Indexable_Repository $indexable_repository ) {
public function __construct(
Post_Type_Helper $post_type_helper,
Indexable_Builder $indexable_builder,
Indexable_Repository $indexable_repository
) {

$this->post_type_helper = $post_type_helper;
$this->indexable_builder = $indexable_builder;
Expand All @@ -63,7 +67,7 @@ public function __construct( Post_Type_Helper $post_type_helper, Indexable_Build
* Rebuilds the indexables for post type archives.
*
* @param Last_Batch_Count $last_batch_count The last batch count domain object.
* @param Batch_Size $batch_size The batch size domain object.
* @param Batch_Size $batch_size The batch size domain object.
*
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Verify_Term_Indexables_Action implements Verify_Indexables_Action_Interfac
/**
* The constructor.
*
* @param Taxonomy_Helper $taxonomy The taxonomy helper.
* @param Taxonomy_Helper $taxonomy The taxonomy helper.
* @param Indexable_Repository $repository The indexable repository.
*/
public function __construct( Taxonomy_Helper $taxonomy, Indexable_Repository $repository ) {
Expand All @@ -50,7 +50,7 @@ public function __construct( Taxonomy_Helper $taxonomy, Indexable_Repository $re
* Re builds indexables for term indexables.
*
* @param Last_Batch_Count $last_batch_count The last batch count domain object.
* @param Batch_Size $batch_size The batch size domain object.
* @param Batch_Size $batch_size The batch size domain object.
*
* @return bool
*/
Expand Down Expand Up @@ -83,7 +83,7 @@ public function set_wpdb( \wpdb $wpdb ) {
/**
* Creates the query to get all the taxonomies.
*
* @param int $limit The query limit.
* @param int $limit The query limit.
* @param int $batch_size The batch size for the queries.
*
* @return string|null
Expand All @@ -100,7 +100,8 @@ private function get_query( $limit, $batch_size ) {
$offset_query = '';
if ( $limit !== 0 ) {
$offset_query = ' OFFSET %d';
$replacements[] = ( $limit + $batch_size );}
$replacements[] = ( $limit + $batch_size );
}

// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
return $this->wpdb->prepare(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Verify_Term_Links_Indexables_Action implements Verify_Indexables_Action_In
/**
* The constructor.
*
* @param Taxonomy_Helper $taxonomy The taxonomy helper.
* @param Indexable_Repository $repository The indexable repository.
* @param Taxonomy_Helper $taxonomy The taxonomy helper.
* @param Indexable_Repository $repository The indexable repository.
* @param Indexable_Link_Builder $link_builder The link builder.
*/
public function __construct(
Expand All @@ -64,7 +64,7 @@ public function __construct(
* Re builds indexables for term links.
*
* @param Last_Batch_Count $last_batch_count The last batch count domain object.
* @param Batch_Size $batch_size The batch size domain object.
* @param Batch_Size $batch_size The batch size domain object.
*
* @return bool
*/
Expand Down Expand Up @@ -113,7 +113,7 @@ public function set_wpdb( \wpdb $wpdb ) {
/**
* Creates the query to get all the taxonomy link options.
*
* @param int $limit The query limit.
* @param int $limit The query limit.
* @param int $batch_size The batch size for the queries.
*
* @return string|null
Expand All @@ -133,6 +133,7 @@ private function get_query( $limit, $batch_size ) {
$offset_query = 'OFFSET %d';
$replacements[] = ( $limit + $batch_size );
}

// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
return $this->wpdb->prepare(
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Yoast\WP\SEO\Indexables\User_Interface;

use Yoast\WP\SEO\Conditionals\Traits\Admin_Conditional_Trait;
use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Indexables\Application\Verification_Cron_Schedule_Handler;
use Yoast\WP\SEO\Integrations\Integration_Interface;

Expand Down
Loading

0 comments on commit a22a22d

Please sign in to comment.