*/ public $errors = array(); /** * Warnings: list of [code, text]. * * @var array */ public $warnings = array(); /** * Human-readable details (category name, colour, size, brand). * * @var array */ public $info = array(); /** * Adds an error. * * @param string $code Code. * @param string $text English text. * @param array $args Values the text is about (for example the field name), for the translated message. */ public function error( string $code, string $text, array $args = array() ): void { $this->errors[] = array( 'code' => $code, 'text' => $text, ) + ( $args ? array( 'args' => $args ) : array() ); } /** * Adds a warning. * * @param string $code Code. * @param string $text English text. * @param array $args Values the text is about (for example the field name), for the translated message. */ public function warn( string $code, string $text, array $args = array() ): void { $this->warnings[] = array( 'code' => $code, 'text' => $text, ) + ( $args ? array( 'args' => $args ) : array() ); } /** * Whether the advert may be published. */ public function is_ready(): bool { return ! $this->errors; } /** * Fingerprint of the advert (to detect changes after publishing). */ public function hash(): string { return null === $this->listing ? '' : $this->listing->hash(); } }