PHP 8.2.31
Preview: PairSet.php Size: 1.32 KB
//home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/lib/packages/GraphQL/Utils/PairSet.php

<?php declare(strict_types=1);

namespace Automattic\WooCommerce\Vendor\GraphQL\Utils;

/**
 * A way to keep track of pairs of things when the ordering of the pair does
 * not matter. We do this by maintaining a sort of double adjacency sets.
 */
class PairSet
{
    /** @var array<string, array<string, bool>> */
    private array $data = [];

    public function has(string $a, string $b, bool $areMutuallyExclusive): bool
    {
        $first = $this->data[$a] ?? null;
        $result = $first !== null && isset($first[$b]) ? $first[$b] : null;
        if ($result === null) {
            return false;
        }

        // areMutuallyExclusive being false is a superset of being true,
        // hence if we want to know if this PairSet "has" these two with no
        // exclusivity, we have to ensure it was added as such.
        if ($areMutuallyExclusive === false) {
            return $result === false;
        }

        return true;
    }

    public function add(string $a, string $b, bool $areMutuallyExclusive): void
    {
        $this->pairSetAdd($a, $b, $areMutuallyExclusive);
        $this->pairSetAdd($b, $a, $areMutuallyExclusive);
    }

    private function pairSetAdd(string $a, string $b, bool $areMutuallyExclusive): void
    {
        $this->data[$a] ??= [];
        $this->data[$a][$b] = $areMutuallyExclusive;
    }
}

Directory Contents

Dirs: 0 × Files: 17

Name Size Perms Modified Actions
22.85 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
23.70 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
35.02 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
19.06 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
9.93 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
1.03 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
391 B lrw-r--r-- 2026-05-05 14:26:50
Edit Download
3.68 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
5.76 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
1.32 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
1.48 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
23.58 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
18.67 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
3.72 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
15.23 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
7.98 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
9.05 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).