File "DisplayManager.php"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/Helper/DisplayManager.php
File size: 1.01 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/**
 * Helper to manage the field display behaviour.
 *
 * @package WooCommerce\PayPalCommerce\WcGateway\Helper;
 */

declare(strict_types=1);

namespace WooCommerce\PayPalCommerce\WcGateway\Helper;

use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;

/**
 * DisplayManager class.
 */
class DisplayManager {

	/**
	 * The settings.
	 *
	 * @var Settings
	 */
	private $settings;

	/**
	 * The rules.
	 *
	 * @var array
	 */
	protected $rules = array();

	/**
	 * FieldDisplayManager constructor.
	 *
	 * @param Settings $settings The settings.
	 * @return void
	 */
	public function __construct( Settings $settings ) {
		$this->settings = $settings;
	}

	/**
	 * Creates and returns a rule.
	 *
	 * @param string|null $key The rule key.
	 * @return DisplayRule
	 */
	public function rule( string $key = null ): DisplayRule {
		if ( null === $key ) {
			$key = '_rule_' . ( (string) count( $this->rules ) );
		}

		$rule = new DisplayRule( $key, $this->settings );

		$this->rules[ $key ] = $rule;
		return $rule;
	}

}