1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Sync;
4:
5: use Salient\Contract\Collection\CollectionInterface;
6: use Salient\Contract\Console\ConsoleWriterInterface;
7: use Stringable;
8:
9: /**
10: * @extends CollectionInterface<int,SyncErrorInterface>
11: */
12: interface SyncErrorCollectionInterface extends CollectionInterface, Stringable
13: {
14: /**
15: * Get the number of errors in the collection
16: */
17: public function getErrorCount(): int;
18:
19: /**
20: * Get the number of warnings in the collection
21: */
22: public function getWarningCount(): int;
23:
24: /**
25: * Get a JSON:API-compatible representation of errors in the collection
26: * after grouping them by level, type and message
27: *
28: * @return array<array{code:string,title:string,detail:string,meta:array{level:string,count:int,seen:int,values:list<mixed[]|object|int|float|string|bool|null>}}>
29: */
30: public function getSummary(): array;
31:
32: /**
33: * Get a human-readable representation of errors in the collection after
34: * grouping them by level, type and message
35: */
36: public function getSummaryText(): string;
37:
38: /**
39: * Write errors in the collection to the console after grouping them by
40: * level, type and message
41: *
42: * Output is written to the console with level:
43: * - NOTICE if no errors have been recorded
44: * - ERROR if one or more recorded errors have level ERROR or higher
45: * - WARNING if all recorded errors have level WARNING or lower
46: *
47: * @param ConsoleWriterInterface|null $writer If `null`, the default console
48: * writer is used.
49: */
50: public function reportErrors(
51: ?ConsoleWriterInterface $writer = null,
52: string $successText = 'No sync errors recorded'
53: ): void;
54:
55: /**
56: * @return array<array{code:string,title:string,detail:string,meta:array{level:string,count:int,seen:int,values:list<mixed[]|object|int|float|string|bool|null>}}>
57: */
58: public function jsonSerialize(): array;
59: }
60: