GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — xmlvalid-php/src/Model/Diagnostic.php at main · xmlvalid/xmlvalid-php Expand file tree/ Copy pathDiagnostic.phpMore file actions 63 lines (56 loc) · 2.46 KB / Copy pathDiagnostic.phpFile metadata and controls63 lines (56 loc) · 2.46 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 <?php declare(strict_types=1); namespace Xmlvalid\Model; use Stringable; /** One error or warning, with where it is and, when there is one, the rule that failed. */ final class Diagnostic implements Stringable { public function __construct( /** 0 when the message is about the whole document. */ public readonly int $line, /** 0 when unknown; business rules point at an element's line only. */ public readonly int $column, /** warning, error or fatal. */ public readonly string $level, /** syntax, xsd, relaxng, dtd, schema, io, schematron (a business rule), archive or pdf. */ public readonly string $type, public readonly string $message, /** The business rule that failed (BR-CO-15, PEPPOL-EN16931-R001) or the PDF check (PDF-AF). */ public readonly ?string $rule = null, /** The message in English, for a rule its publisher wrote in another language. */ public readonly ?string $messageEn = null, /** A page explaining this kind of error and how to fix it. */ public readonly ?string $helpUrl = null, /** The rule's page on xmlvalid.com. */ public readonly ?string $ruleUrl = null, /** Where a business rule fired, as an XPath with the document's prefixes: /Invoice/cac:InvoiceLine[2]/cbc:LineExtensionAmount. */ public readonly ?string $path = null, ) {} /** @param array<string, mixed> $data */ public static function fromArray(array $data): self { return new self( line: Data::int($data, 'line'), column: Data::int($data, 'column'), level: Data::string($data, 'level', 'error'), type: Data::string($data, 'type'), message: Data::string($data, 'message'), rule: Data::nullableString($data, 'rule'), messageEn: Data::nullableString($data, 'message_en'), helpUrl: Data::nullableString($data, 'help_url'), ruleUrl: Data::nullableString($data, 'rule_url'), path: Data::nullableString($data, 'path'), ); } public function isWarning(): bool { return $this->level === 'warning'; } /** "Line 139: [BR-CO-16] Amount due for payment …" */ public function __toString(): string { return ($this->line > 0 ? "Line {$this->line}: " : '') . ($this->rule !== null ? "[{$this->rule}] " : '') . ($this->messageEn ?? $this->message); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |