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/ValueObjects/Targets.php
<?php

declare(strict_types=1);

namespace Pest\Arch\ValueObjects;

use Pest\Expectation;
use PHPUnit\Framework\ExpectationFailedException;

/**
 * @internal
 */
final class Targets
{
    /**
     * Creates a new Target instance.
     *
     * @param  array<int, string>  $value
     */
    public function __construct(
        public readonly array $value,
    ) {
        // ..
    }

    /**
     * Creates a new Target instance from the given "expectation" input.
     *
     * @param  Expectation<array<int, string>|string>  $expectation
     */
    public static function fromExpectation(Expectation $expectation): self
    {
        assert(is_string($expectation->value) || is_array($expectation->value)); // @phpstan-ignore-line

        $values = is_string($expectation->value) ? [$expectation->value] : $expectation->value;

        foreach ($values as $value) {
            if (str_contains($value, '/')) {
                throw new ExpectationFailedException(
                    "Expecting '{$value}' to be a class name or namespace, but it contains a path.",
                );
            }
        }

        return new self($values);
    }
}