*/ private array $reasons = array(); /** * Build the exception from the collected reasons. * * @since 1.0.0 * * @param array $reasons The reasons the delete was refused. * @return self The exception. */ public static function withReasons( array $reasons ): self { $reasons = array_values( array_filter( array_map( 'strval', $reasons ), static fn ( string $reason ): bool => '' !== trim( $reason ) ) ); $exception = new self( implode( ' ', $reasons ) ); $exception->reasons = $reasons; return $exception; } /** * The reasons the delete was refused. * * @since 1.0.0 * * @return array The reasons. */ public function getReasons(): array { return $this->reasons; } }