oauth_storage = $oauth_storage; $this->api_wrapper = $api_wrapper; $this->integration_name = $integration_name; $this->error_handler = $error_handler; $this->scheduler = $scheduler; } public function register_hook() { $hook = 'twofas_update_integration_name'; $this->scheduler->weekly( $hook ); add_action( $hook, [ $this, 'update' ] ); } public function update() { try { $token = $this->oauth_storage->retrieveToken( TokenType::WORDPRESS ); $integration_id = $token->getIntegrationId(); $integration = $this->api_wrapper->get_integration( $integration_id ); $expected_name = $this->integration_name->get_name(); $current_name = $integration->getName(); if ( $current_name !== $expected_name ) { $integration->setName( $expected_name ); $this->api_wrapper->update_integration( $integration ); } } catch ( Exception $e ) { $this->error_handler->capture_exception( $e ); } } }