JFIF  x x C         C     "        } !1AQa "q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz        w !1AQ aq"2B #3Rbr{ gilour

File "DeleteUsersRequest.php"

Full Path: /home/palsarh/web/palsarh.in/public_html/vendor/kreait/firebase-php/src/Firebase/Auth/DeleteUsersRequest.php
File size: 1.27 KB
MIME-type: text/x-php
Charset: utf-8

<?php

declare(strict_types=1);

namespace Kreait\Firebase\Auth;

use Kreait\Firebase\Exception\InvalidArgumentException;
use Kreait\Firebase\Value\Uid;
use Stringable;

/**
 * @internal
 */
final class DeleteUsersRequest
{
    private const MAX_BATCH_SIZE = 1000;

    private function __construct(
        /** @var list<string> $uids */
        private readonly array $uids,
        private readonly bool $enabledUsersShouldBeForceDeleted,
    ) {
    }

    /**
     * @param iterable<Stringable|string> $uids
     */
    public static function withUids(iterable $uids, bool $forceDeleteEnabledUsers = false): self
    {
        $validatedUids = [];
        $count = 0;

        foreach ($uids as $uid) {
            $validatedUids[] = Uid::fromString($uid)->value;
            ++$count;

            if ($count > self::MAX_BATCH_SIZE) {
                throw new InvalidArgumentException('Only '.self::MAX_BATCH_SIZE.' users can be deleted at a time');
            }
        }

        return new self($validatedUids, $forceDeleteEnabledUsers);
    }

    /**
     * @return string[]
     */
    public function uids(): array
    {
        return $this->uids;
    }

    public function enabledUsersShouldBeForceDeleted(): bool
    {
        return $this->enabledUsersShouldBeForceDeleted;
    }
}