$data Rohdaten aus der Option. * @return self */ public static function from_array( array $data ): self { $mode = isset( $data['mode'] ) ? (string) $data['mode'] : self::MODE_DRAFT; return new self( isset( $data['id'] ) ? (int) $data['id'] : 0, isset( $data['aivor_job_id'] ) ? (string) $data['aivor_job_id'] : '', isset( $data['post_type'] ) ? (string) $data['post_type'] : 'post', isset( $data['taxonomy'] ) ? (string) $data['taxonomy'] : '', isset( $data['term_id'] ) ? (int) $data['term_id'] : 0, isset( $data['author_id'] ) ? (int) $data['author_id'] : 0, in_array( $mode, self::modes(), true ) ? $mode : self::MODE_DRAFT, ! empty( $data['enable_comments'] ), isset( $data['error'] ) ? (string) $data['error'] : '', isset( $data['last_import'] ) ? (int) $data['last_import'] : 0, isset( $data['site_hash'] ) ? (string) $data['site_hash'] : '', isset( $data['remote_name'] ) ? (string) $data['remote_name'] : '', isset( $data['remote_site_url'] ) ? (string) $data['remote_site_url'] : '', isset( $data['remote_status'] ) ? (string) $data['remote_status'] : '', isset( $data['checked_at'] ) ? (int) $data['checked_at'] : 0 ); } /** * Die gueltigen Modi. * * Importierte Beitraege gehen nie ohne menschliche Freigabe online: Die * Review-Checkliste von WordPress.org fuehrt automatisch postende Plugins * als Grey-Hat-SEO. Ein frueher gespeicherter Modus „publish" wird beim * Lesen zum Entwurf. * * @return string[] */ public static function modes(): array { return array( self::MODE_DRAFT, self::MODE_PENDING ); } /** * Wandelt den Job in ein speicherbares Array. * * @return array */ public function to_array(): array { return array( 'id' => $this->id, 'aivor_job_id' => $this->aivor_job_id, 'post_type' => $this->post_type, 'taxonomy' => $this->taxonomy, 'term_id' => $this->term_id, 'author_id' => $this->author_id, 'mode' => $this->mode, 'enable_comments' => $this->enable_comments, 'error' => $this->error, 'last_import' => $this->last_import, 'site_hash' => $this->site_hash, 'remote_name' => $this->remote_name, 'remote_site_url' => $this->remote_site_url, 'remote_status' => $this->remote_status, 'checked_at' => $this->checked_at, ); } /** * Liefert eine Kopie mit geaenderten Feldern. * * @param array $changes Zu setzende Felder. * @return self */ public function with( array $changes ): self { return self::from_array( array_merge( $this->to_array(), $changes ) ); } }