2017-07-15 13:04:12 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-07-15 13:04:12 +03:00
|
|
|
namespace Shlinkio\Shlink\Core\Exception;
|
|
|
|
|
2018-10-28 10:34:02 +03:00
|
|
|
use function implode;
|
|
|
|
use function sprintf;
|
|
|
|
|
2017-12-30 23:35:26 +03:00
|
|
|
class EntityDoesNotExistException extends RuntimeException
|
2017-07-15 13:04:12 +03:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|