-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNoResponse.php
35 lines (26 loc) · 931 Bytes
/
NoResponse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
namespace Vural\OpenAPIFaker\Exception;
use Exception;
use function Safe\sprintf;
class NoResponse extends Exception
{
protected string $method;
protected string $path;
protected string|null $statusCode = null;
public static function forPathAndMethod(string $path, string $method): self
{
$e = new self(sprintf('OpenAPI spec does not have a response for %s %s', $method, $path));
$e->path = $path;
$e->method = $method;
return $e;
}
public static function forPathAndMethodAndStatusCode(string $path, string $method, string $statusCode): self
{
$e = new self(sprintf('OpenAPI spec does not have a response for status code %s at %s %s', $statusCode, $method, $path));
$e->path = $path;
$e->method = $method;
$e->statusCode = $statusCode;
return $e;
}
}