GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
File: /var/www/admin.fixgini.com/vendor/pestphp/pest-plugin-arch/src/GroupArchExpectation.php
<?php

declare(strict_types=1);

namespace Pest\Arch;

use Closure;
use Pest\Arch\Contracts\ArchExpectation;
use Pest\Expectation;

/**
 * @internal
 *
 * @mixin Expectation<string>
 */
final class GroupArchExpectation implements Contracts\ArchExpectation
{
    /**
     * Creates a new Arch Expectation instance.
     *
     * @param  array<int, GroupArchExpectation|SingleArchExpectation>  $expectations
     */
    private function __construct(private readonly Expectation $original, private readonly array $expectations)
    {
        // ...
    }

    /**
     * Ignores the given layers.
     *
     * @param  array<int, string>|string  $targetsOrDependencies
     * @return $this
     */
    public function ignoring(array|string $targetsOrDependencies): self
    {
        foreach ($this->expectations as $expectation) {
            $expectation->ignoring($targetsOrDependencies);
        }

        return $this;
    }

    /**
     * Ignores the global "user defined" functions.
     *
     * @return $this
     */
    public function ignoringGlobalFunctions(): self
    {
        foreach ($this->expectations as $expectation) {
            $expectation->ignoringGlobalFunctions();
        }

        return $this;
    }

    /**
     * Sets the "opposite" callback.
     */
    public function opposite(Closure $callback): self
    {
        foreach ($this->expectations as $expectation) {
            $expectation->opposite($callback);
        }

        return $this;
    }

    /**
     * Creates a new Arch Expectation instance from the given expectations.
     *
     * @param  array<int, GroupArchExpectation|SingleArchExpectation>  $expectations
     */
    public static function fromExpectations(Expectation $original, array $expectations): self
    {
        return new self($original, $expectations);
    }

    /**
     * Proxies the call to the first expectation.
     *
     * @param  array<array-key, mixed>  $arguments
     * @return Expectation<string>
     */
    public function __call(string $name, array $arguments): mixed
    {
        $this->ensureLazyExpectationIsVerified();

        return $this->original->$name(...$arguments); // @phpstan-ignore-line
    }

    /**
     * Proxies the call to the expectation.
     *
     * @return Expectation<string>
     */
    public function __get(string $name): mixed
    {
        $this->ensureLazyExpectationIsVerified();

        return $this->original->$name; // @phpstan-ignore-line
    }

    /**
     * {@inheritDoc}
     */
    public function mergeExcludeCallbacks(array $excludeCallbacks): void
    {
        foreach ($this->expectations as $expectation) {
            $expectation->mergeExcludeCallbacks($excludeCallbacks);
        }
    }

    /**
     * {@inheritDoc}
     */
    public function excludeCallbacks(): array
    {
        return array_merge(...array_map(
            fn (ArchExpectation $expectation): array => $expectation->excludeCallbacks(), $this->expectations,
        ));
    }

    /**
     * Ensures the lazy expectation is verified when the object is destructed.
     */
    public function __destruct()
    {
        $this->ensureLazyExpectationIsVerified();
    }

    /**
     * Ensures the lazy expectation is verified.
     */
    private function ensureLazyExpectationIsVerified(): void
    {
        foreach ($this->expectations as $expectation) {
            $expectation->ensureLazyExpectationIsVerified();
        }
    }
}