<?php

namespace ModernFields\FieldGroups\Repositories;

use ModernFields\FieldGroups\Entities\Post;


/**
 * Post Repository
 * 
 * This class is responsible for retrieving post data from the database.
 * 
 * @since 1.0.0
 */
class PostRepository
{
  /**
   * Get a post by its ID.
   * 
   * @param int $post_id The ID of the post to retrieve.
   * @return Post|null The post object if found, null otherwise.
   */
  public static function getPostById($post_id): ?Post
  {
    $post = get_post($post_id);

    if (!$post) {
      return null;
    }

    return new Post($post);
  }
}
