|ArchExpectation> */ protected array $expectations = []; /** * Creates a new preset instance. * * @param array $userNamespaces */ public function __construct( private readonly array $userNamespaces, ) { // } /** * Executes the arch preset. * * @internal */ abstract public function execute(): void; /** * Ignores the given "targets" or "dependencies". * * @param array|string $targetsOrDependencies */ final public function ignoring(array|string $targetsOrDependencies): void { $this->expectations = array_map( fn (ArchExpectation|Expectation $expectation): Expectation|ArchExpectation => $expectation instanceof ArchExpectation ? $expectation->ignoring($targetsOrDependencies) : $expectation, $this->expectations, ); } /** * Runs the given callback for each namespace. * * @param callable(Expectation): ArchExpectation ...$callbacks */ final public function eachUserNamespace(callable ...$callbacks): void { foreach ($this->userNamespaces as $namespace) { foreach ($callbacks as $callback) { $this->expectations[] = $callback(expect($namespace)); } } } /** * Flushes the expectations. */ final public function flush(): void { $this->expectations = []; } }