Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
1 / 3
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SearchException
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 invalidMode
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 accessDenied
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\Search\Domain\Exception;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use RuntimeException;
12
13/**
14 * Search Domain Exception.
15 *
16 * Thrown when search validation, parsing, or execution constraints are violated.
17 *
18 * @package App\Core\Search\Domain\Exception
19 */
20final class SearchException extends RuntimeException
21{
22    /**
23     * Creates an exception for an invalid search mode.
24     *
25     * @param string $mode Unknown mode string.
26     * @return self New instance.
27     */
28    public static function invalidMode(string $mode): self
29    {
30        return new self(sprintf('Invalid search mode "%s".', $mode));
31    }
32
33    /**
34     * Creates an exception for an unpermitted module search.
35     *
36     * @param string $moduleName Module name.
37     * @return self New instance.
38     */
39    public static function accessDenied(string $moduleName): self
40    {
41        return new self(sprintf('Access denied for module "%s".', $moduleName));
42    }
43}