<commit_before><?php

if (!class_exists('CM_WP_Element_PostType_Post')) {

    class CM_WP_Element_PostType_Post {
        
        /***************************************
         * Static factory properties & methods *
         ***************************************/

        /**
         * Creates a CM_WP_Post object from a WP_Post object
         *
         * @param WP_Post $post WP_Post object containing post details
         *
         * @return CM_WP_Element_PostType_Post
         */
        static public function create_from_post( WP_Post $post ) {
            $class = get_called_class();
            $post_obj = new $class;
            $post_obj->set_post( $post );

            return $post_obj;
        }



        /*******************************
         * Object properties & methods *
         *******************************/

        /**
         * Stores the WP_Post object containing the post's details
         *
         * @var WP_Post
         */
        protected $wp_post;





        /**************************
         * Getters, setters, etc. *
         **************************/

        /**
         * Sets the post for this object
         *
         * @param WP_Post $post WP_Post object to be set
         *
         * @throws  RuntimeException if the wp_post property has already been set
         *
         * @return void
         */
        protected function set_post( WP_Post $post ) {
            if ( isset( $tthis->wp_post ) ) {
                throw new RuntimeException( "Post has already been set" );
            }

            $this->wp_post = $post;
        }


        /**
         * Returns the ID of the post
         *
         * @return int
         */
        public function get_ID() {
            return $this->wp_post->ID;
        }
    }
}<commit_msg>Added method to publish posts.<commit_after><?php

if (!class_exists('CM_WP_Element_PostType_Post')) {

    class CM_WP_Element_PostType_Post {
        
        /***************************************
         * Static factory properties & methods *
         ***************************************/

        /**
         * Creates a CM_WP_Post object from a WP_Post object
         *
         * @param WP_Post $post WP_Post object containing post details
         *
         * @return CM_WP_Element_PostType_Post
         */
        static public function create_from_post( WP_Post $post ) {
            $class = get_called_class();
            $post_obj = new $class;
            $post_obj->set_post( $post );

            return $post_obj;
        }



        /*******************************
         * Object properties & methods *
         *******************************/

        /**
         * Stores the WP_Post object containing the post's details
         *
         * @var WP_Post
         */
        protected $wp_post;





        /**
         * Updated the saved post data
         *
         * @return $this (for method chaining)
         */
        protected function update_post() {
            $post = get_post( $this->get_ID() );

            $this->wp_post = $post;

            return $this;
        }

        /**
         * Saves the current post to the database
         *
         * @return $this (for method chaining)
         */
        protected function save() {
            wp_update_post( $this->wp_post );
        }


        /**
         * Publishes the post
         * @return void
         */
        public function publish() {
            $this->set_status( 'publish' );
        }





        /**************************
         * Getters, setters, etc. *
         **************************/

        /**
         * Sets the post for this object
         *
         * @param WP_Post $post WP_Post object to be set
         *
         * @throws  RuntimeException if the wp_post property has already been set
         *
         * @return void
         */
        protected function set_post( WP_Post $post ) {
            if ( isset( $tthis->wp_post ) ) {
                throw new RuntimeException( "Post has already been set" );
            }

            $this->wp_post = $post;
        }


        /**
         * Returns the ID of the post
         *
         * @return int
         */
        public function get_ID() {
            return $this->wp_post->ID;
        }


        /**
         * Sets the post status
         *
         * @param string $status The status to set to
         *
         * @return void
         */
        public function set_status( $status ) {
            $this->update_post();
            $this->wp_post->post_status = $status;
            $this->save();
        }
    }
}
{'fraction_non_alphanumeric': 0.16709456568249892, 'fraction_numerical': 0.0, 'mean_word_length': 1.4579390115667719, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3086648', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1178, 'n_words': 307}