File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Lkrms \Sync \Exception ;
4+
5+ use Lkrms \Sync \Contract \ISyncEntity ;
6+ use Lkrms \Sync \Contract \ISyncProvider ;
7+ use Throwable ;
8+
9+ /**
10+ * Thrown when an entity has invalid data or is not the droid you're looking for
11+ */
12+ class SyncInvalidEntityException extends SyncException
13+ {
14+ protected ISyncProvider $ Provider ;
15+
16+ protected string $ EntityType ;
17+
18+ /**
19+ * @var int|string|null
20+ */
21+ protected $ EntityId ;
22+
23+ protected ?ISyncEntity $ Entity ;
24+
25+ /**
26+ * Creates a new SyncInvalidEntityException object
27+ *
28+ * @template T of ISyncEntity
29+ *
30+ * @param class-string<T> $entityType
31+ * @param T|int|string|null $entityOrId
32+ */
33+ public function __construct (
34+ string $ message ,
35+ ISyncProvider $ provider ,
36+ string $ entityType ,
37+ $ entityOrId ,
38+ ?Throwable $ previous = null
39+ ) {
40+ $ this ->Provider = $ provider ;
41+ $ this ->EntityType = $ entityType ;
42+
43+ if ($ entityOrId instanceof ISyncEntity) {
44+ $ this ->Entity = $ entityOrId ;
45+ $ this ->EntityId = $ this ->Entity ->id ();
46+ } else {
47+ $ this ->EntityId = $ entityOrId ;
48+ $ this ->Entity = null ;
49+ }
50+
51+ parent ::__construct ($ message , $ previous );
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments