<?php
namespace Wpupgrader\WordPress\Plugins\GdprConsentLite;

class Consent
{
    public $post;

    public function __construct($post)
    {
        $this->post = $post;
    }

    public function getCookieId()
    {
        return $this->getId();
    }

    public function getId()
    {
        return $this->post->ID;
    }

    public function isRequired()
    {
        return $this->getPostMeta('gdprc_consent_is_required');
    }

    private function getPostMeta($key)
    {
        return \get_post_meta($this->getId(), $key, true);
    }

    public function getTitle()
    {
        return $this->post->post_title;
    }

    public function getHashTag()
    {
        return \lcfirst(\preg_replace('~\s+~i', '', \ucwords($this->post->post_title)));
    }

    public function getIcon()
    {
        // Compatibility script for backward conversion of FA- to GDPRI- icons
        return \preg_replace('~^fa-~i', 'gdpri-', $this->getPostMeta('gdprc_selected_icon'));
    }

    public function getContent()
    {
        return $this->post->post_content;
    }
}