<?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 Session {

    private static $session = null;

    private static function getJoomlaSession() {
        if (!is_object(self::$session)) {
            self::$session = Factory::getApplication()->getSession();
        }
    }

    public static function set($name, $value = null) {
        self::getJoomlaSession();
        self::$session->set(__NAMESPACE__ . '\\' . $name, $value);
    }

    public static function get($name, $default = null) {
        self::getJoomlaSession();
        return trim((string) self::$session->get(__NAMESPACE__ . '\\' . $name, $default));
    }

    public static function checkToken($method = 'post') {
        return \Joomla\CMS\Session\Session::checkToken($method);
    }

}
