*/ public array $extra; public string $error; /** * @param string $id * @param string $name * @param string $label * @param string $error * @param array $extra */ public function __construct(string $id, string $name, string $label, string $error, array $extra = []) { $this->id = $id; $this->name = $name; $this->label = $label; $this->error = $error; $this->extra = $extra; } /** * @param \stdClass $row A row of the repository's list query * @param \Throwable $error * @param string $nameProp The row property holding the record's name * @param string $labelProp The row property holding the record's label * @param array $extra * @return self */ public static function fromRow(\stdClass $row, \Throwable $error, string $nameProp = 'name', string $labelProp = 'label', array $extra = []): self { return new self( (string)($row->id ?? ''), (string)($row->{$nameProp} ?? ''), (string)($row->{$labelProp} ?? ''), $error->getMessage(), $extra ); } /** * @return array */ #[\ReturnTypeWillChange] public function jsonSerialize() { return array_merge($this->extra, [ 'id' => $this->id, 'name' => $this->name, 'label' => $this->label, 'broken' => true, 'error' => $this->error, ]); } }