HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/shoetique/wp-content/plugins/woocommerce/vendor/pelago/emogrifier/src/Css/StyleRule.php
<?php

declare(strict_types=1);

namespace Pelago\Emogrifier\Css;

use Sabberworm\CSS\Property\Selector;
use Sabberworm\CSS\RuleSet\DeclarationBlock;

/**
 * This class represents a CSS style rule, including selectors, a declaration block, and an optional containing at-rule.
 *
 * @internal
 */
class StyleRule
{
    /**
     * @var DeclarationBlock
     */
    private $declarationBlock;

    /**
     * @var string
     */
    private $containingAtRule;

    /**
     * @param DeclarationBlock $declarationBlock
     * @param string $containingAtRule e.g. `@media screen and (max-width: 480px)`
     */
    public function __construct(DeclarationBlock $declarationBlock, string $containingAtRule = '')
    {
        $this->declarationBlock = $declarationBlock;
        $this->containingAtRule = \trim($containingAtRule);
    }

    /**
     * @return array<int, string> the selectors, e.g. `["h1", "p"]`
     */
    public function getSelectors(): array
    {
        /** @var array<int, Selector> $selectors */
        $selectors = $this->declarationBlock->getSelectors();
        return \array_map(
            static function (Selector $selector): string {
                return (string)$selector;
            },
            $selectors
        );
    }

    /**
     * @return string the CSS declarations, separated and followed by a semicolon, e.g., `color: red; height: 4px;`
     */
    public function getDeclarationAsText(): string
    {
        return \implode(' ', $this->declarationBlock->getRules());
    }

    /**
     * Checks whether the declaration block has at least one declaration.
     */
    public function hasAtLeastOneDeclaration(): bool
    {
        return $this->declarationBlock->getRules() !== [];
    }

    /**
     * @returns string e.g. `@media screen and (max-width: 480px)`, or an empty string
     */
    public function getContainingAtRule(): string
    {
        return $this->containingAtRule;
    }

    /**
     * Checks whether the containing at-rule is non-empty and has any non-whitespace characters.
     */
    public function hasContainingAtRule(): bool
    {
        return $this->getContainingAtRule() !== '';
    }
}