1: <?php declare(strict_types=1);
2:
3: namespace Salient\Sync\Exception;
4:
5: use Salient\Contract\Sync\Exception\SyncEntityNotFoundExceptionInterface;
6: use Salient\Contract\Sync\SyncEntityInterface;
7: use Salient\Contract\Sync\SyncProviderInterface;
8: use Salient\Utility\Format;
9: use Throwable;
10:
11: /**
12: * @api
13: */
14: class SyncEntityNotFoundException extends AbstractSyncException implements SyncEntityNotFoundExceptionInterface
15: {
16: /**
17: * @param class-string<SyncEntityInterface> $entity
18: * @param int|string|array<string,mixed> $idOrFilter
19: */
20: public function __construct(
21: SyncProviderInterface $provider,
22: string $entity,
23: $idOrFilter,
24: ?Throwable $previous = null
25: ) {
26: $idOrFilter = is_array($idOrFilter)
27: ? $idOrFilter
28: : ['id' => $idOrFilter];
29:
30: parent::__construct(sprintf(
31: '%s does not have %s with %s',
32: $this->getProviderName($provider),
33: $entity,
34: Format::array($idOrFilter, '%s = {%s}, ', 0, ', '),
35: ), $previous);
36: }
37: }
38: