_buffer = $buffer; $this->_offset = $offset; $this->_status = $status; parent::__construct( sprintf( 'Invalid char "%s" for status "%s" at offset #%d in "%s"', $this->getChar(), get_class($this->_status), $this->_offset, $this->_buffer ) ); } /** * Match the utf-8 character at the byte offset position. * * @return string */ public function getChar(): string { if (preg_match('(.)suS', $this->_buffer, $match, 0, $this->_offset)) { return $match[0]; } return ''; } public function getOffset(): int { return $this->_offset; } public function getBuffer(): string { return $this->_buffer; } public function getStatus(): Status { return $this->_status; } } }