init($array); } /** * @param array $array * @return void */ private function init(array $array): void { foreach ($array as $key => $value) { if (!property_exists($this, $key)) { continue; } $this->{$key} = $value; } } /** * @param string $field * @return mixed */ public function get(string $field): mixed { return $this->$field; } /** * @return bool * 是否已完成支付 */ public function isPaid(): bool { return $this->state == self::RED_HAT_STATUS_PAID; } /** * @return bool * 是否已抢完 */ public function isSnatched(): bool { return $this->state == self::RED_HAT_STATUS_SNATCHED; } /** * @return bool */ public function isExpired(): bool { return $this->state == self::RED_HAT_STATUS_EXPIRED; } /** * @return bool */ public function isRefunded(): bool { return $this->state == self::RED_HAT_STATUS_REFUNDED; } }