<commit_before><?php

/**
 * Custom Template
 *
 * @package GrottoPress\Jentil\Utilities
 * @since 0.6.0
 *
 * @author GrottoPress <<EMAIL>>
 * @author <NAME>
 */

declare (strict_types = 1);

namespace GrottoPress\Jentil\Utilities;

/**
 * Custom Template
 *
 * @since 0.6.0
 */
final class CustomTemplate
{
    /**
     * Utilities
     *
     * @since 0.6.0
     * @access private
     *
     * @var Utilities
     */
    private $utilities;

    /**
     * Constructor
     *
     * @param Utilities $utilities
     *
     * @since 0.6.0
     * @access public
     */
    public function __construct(Utilities $utilities)
    {
        $this->utilities = $utilities;
    }

    /**
     * Are we on a page builder page?
     *
     * @since 0.6.0
     * @access public
     *
     * @return bool
     */
    public function isPageBuilder(): bool
    {
        return $this->is(['page-builder.php', 'page-builder-blank.php']);
    }

    /**
     * Are we on a given page template?
     *
     * @param array $type
     *
     * @since 0.6.0
     * @access public
     *
     * @return bool
     */
    public function is(array $type): bool
    {
        return $this->utilities->page->is('page_template', $type);
    }
}
<commit_msg>Allow getting page template slug by post id<commit_after><?php

/**
 * Custom Template
 *
 * @package GrottoPress\Jentil\Utilities
 * @since 0.6.0
 *
 * @author GrottoPress <<EMAIL>>
 * @author <NAME>
 */

declare (strict_types = 1);

namespace GrottoPress\Jentil\Utilities;

/**
 * Custom Template
 *
 * @since 0.6.0
 */
final class CustomTemplate
{
    /**
     * Utilities
     *
     * @since 0.6.0
     * @access private
     *
     * @var Utilities
     */
    private $utilities;

    /**
     * Constructor
     *
     * @param Utilities $utilities
     *
     * @since 0.6.0
     * @access public
     */
    public function __construct(Utilities $utilities)
    {
        $this->utilities = $utilities;
    }

    /**
     * Is page a page builder page?
     *
     * @param int $post_id
     *
     * @since 0.6.0
     * @access public
     *
     * @return bool
     */
    public function isPageBuilder(int $post_id = null): bool
    {
        if ($post_id) {
            return \in_array(
                $this->slug($post_id),
                ['page-builder.php', 'page-builder-blank.php']
            );
        }

        return $this->is(['page-builder.php', 'page-builder-blank.php']);
    }

    /**
     * Get page template slug
     *
     * @param int $post_id
     *
     * @since 0.6.0
     * @access public
     *
     * @return string
     */
    public function slug(int $post_id = null): string
    {
        return (string)\get_page_template_slug($post_id);
    }

    /**
     * Are we on a given page template?
     *
     * @param array $type
     *
     * @since 0.6.0
     * @access public
     *
     * @return bool
     */
    public function is(array $type): bool
    {
        return $this->utilities->page->is('page_template', $type);
    }
}

{'fraction_non_alphanumeric': 0.1403973509933775, 'fraction_numerical': 0.013576158940397352, 'mean_word_length': 1.7563868613138687, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, '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': '1202977', 'n_tokens_mistral': 1031, 'n_tokens_neox': 1010, 'n_words': 221}