Uname:Linux server.rehabsharif.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64

Base Dir : /home/nobi37te/public_html

User : nobi37te


403WebShell
403Webshell
Server IP : 104.21.25.182  /  Your IP : 216.73.216.203
Web Server : Apache
System : Linux server.rehabsharif.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : nobi37te ( 1003)
PHP Version : 8.2.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/nobi37te/public_html/wp-content/plugins/sfwd-lms/src/Core/Factories/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/nobi37te/public_html/wp-content/plugins/sfwd-lms/src/Core/Factories/Model.php
<?php
/**
 * A factory class for creating models from posts.
 *
 * @since 4.6.0
 *
 * @package LearnDash\Core
 */

/** NOTICE: This code is currently under development and may not be stable.
 *  Its functionality, behavior, and interfaces may change at any time without notice.
 *  Please refrain from using it in production or other critical systems.
 *  By using this code, you assume all risks and liabilities associated with its use.
 *  Thank you for your understanding and cooperation.
 **/

namespace LearnDash\Core\Factories;

use InvalidArgumentException;
use LDLMS_Post_Types;
use LearnDash\Core\Models\Course;
use LearnDash\Core\Models\Group;
use LearnDash\Core\Models\Lesson;
use LearnDash\Core\Models\Post;
use LearnDash\Core\Models\Quiz;
use LearnDash\Core\Models\Topic;
use WP_Post;

// TODO: Add tests.

/**
 * A factory class for creating models from posts.
 *
 * @since 4.6.0
 */
class Model {
	/**
	 * Creates a model from a post based on the post type.
	 *
	 * @since 4.6.0
	 *
	 * @param WP_Post $post Post.
	 *
	 * @throws InvalidArgumentException If the post type is invalid.
	 *
	 * @return Post
	 */
	public static function create_from_post( WP_Post $post ): Post {
		switch ( LDLMS_Post_Types::get_post_type_key( $post->post_type ) ) {
			case LDLMS_Post_Types::COURSE:
				return Course::create_from_post( $post );
			case LDLMS_Post_Types::GROUP:
				return Group::create_from_post( $post );
			case LDLMS_Post_Types::LESSON:
				return Lesson::create_from_post( $post );
			case LDLMS_Post_Types::TOPIC:
				return Topic::create_from_post( $post );
			case LDLMS_Post_Types::QUIZ:
				return Quiz::create_from_post( $post );
			default:
				throw new InvalidArgumentException( 'Invalid post type' );
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit