HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/AdsService.php.tar
vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/google-listings-and-ads/src/Ads/AdsService.php000064400000003740151546276710031107 0ustar00var/www<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Ads;

use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\AdsAccountState;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsAwareInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsAwareTrait;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;

defined( 'ABSPATH' ) || exit;

/**
 * Class AdsService
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Ads
 */
class AdsService implements OptionsAwareInterface, Service {

	use OptionsAwareTrait;

	/** @var AdsAccountState */
	protected $account_state;

	/**
	 * AdsService constructor.
	 *
	 * @since 1.11.0
	 *
	 * @param AdsAccountState $account_state
	 */
	public function __construct( AdsAccountState $account_state ) {
		$this->account_state = $account_state;
	}

	/**
	 * Determine whether Ads setup has been started.
	 *
	 * @since 1.11.0
	 * @return bool
	 */
	public function is_setup_started(): bool {
		return $this->account_state->last_incomplete_step() !== '' && ! $this->is_setup_complete();
	}

	/**
	 * Determine whether Ads setup has completed.
	 *
	 * @return bool
	 */
	public function is_setup_complete(): bool {
		return boolval( $this->options->get( OptionsInterface::ADS_SETUP_COMPLETED_AT, false ) );
	}

	/**
	 * Determine whether Ads has connected.
	 *
	 * @return bool
	 */
	public function is_connected(): bool {
		$google_connected = boolval( $this->options->get( OptionsInterface::GOOGLE_CONNECTED, false ) );
		return $google_connected && $this->is_setup_complete();
	}

	/**
	 * Determine whether the Ads account is connected, even when pending billing.
	 *
	 * @return bool
	 */
	public function connected_account(): bool {
		$id        = $this->options->get_ads_id();
		$last_step = $this->account_state->last_incomplete_step();
		return $id && ( $last_step === '' || $last_step === 'billing' );
	}
}