mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-28 07:28:32 +03:00
30 lines
722 B
PHP
30 lines
722 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\Core\Exception;
|
|
|
|
use function implode;
|
|
use function sprintf;
|
|
|
|
class EntityDoesNotExistException extends RuntimeException
|
|
{
|
|
public static function createFromEntityAndConditions($entityName, array $conditions)
|
|
{
|
|
return new self(sprintf(
|
|
'Entity of type %s with params [%s] does not exist',
|
|
$entityName,
|
|
static::serializeParams($conditions)
|
|
));
|
|
}
|
|
|
|
private static function serializeParams(array $params)
|
|
{
|
|
$result = [];
|
|
foreach ($params as $key => $value) {
|
|
$result[] = sprintf('"%s" => "%s"', $key, $value);
|
|
}
|
|
|
|
return implode(', ', $result);
|
|
}
|
|
}
|