<?php
declare(strict_types=1);

namespace WP_AUX\Services;

use WP_AUX\Entities\AuxFramework\ElementClassesEntity;
use WP_AUX\Entities\PageTemplateEntity;

class PageTemplateService
{
  public static function hasSidebar(): bool
  {
    $auxTemplate = PageTemplateEntity::getRequested();

    return $auxTemplate->sidebar->getType() !== 'none';
  }

  public static function applyInternalPageClass(ElementClassesEntity $componentClasses): void
  {
    if (self::hasSidebar()) {
      $componentClasses->addModifier('internal');
    }
  }

  public static function getBodyClasses(): array
  {
    $auxTemplate = PageTemplateEntity::getRequested();

    $bodyClasses = [
      'aux-header--' . $auxTemplate->header->getType(),
      'aux-layout--' . $auxTemplate->layout->getType(),
      'aux-sidebar--' . $auxTemplate->sidebar->getType(),
    ];

    return $bodyClasses;
  }
}
