<?php

/*
 * @component UserPoints
 * @copyright Copyright (C) Martin Brampton
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

namespace BlackSheepResearch\Component\UserPoints\Site\Utils;

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;

abstract class Cookie {

    private static $cookie = null;
    private static $prefix = 'com_userpoints_';

    private static function getJoomlaCookie() {
        if (!is_object(self::$cookie)) {
            self::$cookie = Factory::getApplication()->input->cookie;
        }
    }

    public static function set($name, $value = null, $expire = 0) {
        self::getJoomlaCookie();
        self::$cookie->set(self::$prefix.$name, $value, $expire);
    }

    public static function get($name, $default = null) {
        self::getJoomlaCookie();
        return trim((string)self::$cookie->get(self::$prefix.$name, $default));
    }

}
