1: <?php
2: declare(strict_types=1);
3:
4: namespace om\ICal\Validation;
5:
6: use Stringable;
7:
8: final readonly class Issue implements Stringable {
9: /**
10: * @param string $code stable identifier, e.g. "event.dtend-and-duration"
11: * @param string $component name of the component, e.g. VEVENT
12: */
13: public function __construct(
14: public Severity $severity,
15: public string $code,
16: public string $message,
17: public string $component,
18: public ?string $property = null,
19: public ?int $line = null,
20: public ?string $uid = null,
21: ) {
22: }
23:
24: public function __toString(): string {
25: return sprintf(
26: '%s %s%s%s: %s [%s]',
27: strtoupper($this->severity->name),
28: $this->component,
29: $this->property !== null ? ".$this->property" : '',
30: $this->line !== null ? " (line $this->line)" : '',
31: $this->message,
32: $this->code,
33: );
34: }
35: }
36: