Use assert instead of long comments

This commit is contained in:
Narek Zakarian 2022-08-17 19:06:20 +04:00
parent 9b63ab0b91
commit 9ea71be37b
2 changed files with 9 additions and 26 deletions

View file

@ -45,19 +45,12 @@ class OrderTrackingModule implements ModuleInterface {
* @throws NotFoundException
*/
public function run( ContainerInterface $c ): void {
/**
* The Settings.
*
* @var Settings $settings
*/
$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
/**
* The PUI helper.
*
* @var PayUponInvoiceHelper $pui_helper
*/
$pui_helper = $c->get( 'wcgateway.pay-upon-invoice-helper' );
assert( $pui_helper instanceof PayUponInvoiceHelper );
if ( $pui_helper->is_pui_ready_in_admin() ) {
$settings->set( 'tracking_enabled', true );
$settings->persist();
@ -73,19 +66,11 @@ class OrderTrackingModule implements ModuleInterface {
assert( $asset_loader instanceof OrderEditPageAssets );
$is_paypal_order_edit_page = $c->get( 'order-tracking.is-paypal-order-edit-page' );
/**
* The tracking Endpoint.
*
* @var OrderTrackingEndpoint $endpoint
*/
$endpoint = $c->get( 'order-tracking.endpoint.controller' );
assert( $endpoint instanceof OrderTrackingEndpoint );
/**
* The logger.
*
* @var LoggerInterface
*/
$logger = $c->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface );
add_action(
'init',

View file

@ -2425,8 +2425,9 @@ return array(
},
'order-tracking.is-tracking-available' => static function ( ContainerInterface $container ): bool {
try {
/* @var Bearer $bearer The bearer. */
$bearer = $container->get( 'api.bearer' );
assert( $bearer instanceof Bearer );
$token = $bearer->bearer();
return $token->is_tracking_available();
} catch ( RuntimeException $exception ) {
@ -2434,12 +2435,9 @@ return array(
}
},
'wcgateway.settings.should-disable-tracking-checkbox' => static function ( ContainerInterface $container ): bool {
/**
* The PUI helper.
*
* @var PayUponInvoiceHelper $pui_helper
*/
$pui_helper = $container->get( 'wcgateway.pay-upon-invoice-helper' );
assert( $pui_helper instanceof PayUponInvoiceHelper );
$is_tracking_available = $container->get( 'order-tracking.is-tracking-available' );
if ( ! $is_tracking_available ) {