<?php

class session
{
    public static function createSession(array $_array, string $_type = "user")
    {
        $_SESSION[$_type] = $_array;
    }

    public static function getId(string $_type = "user")
    {
        return $_SESSION[$_type]["id"];
    }

    public static function getValue(string $_val, string $_type = "user")
    {
        return $_SESSION[$_type][$_val];
    }

    public static function getName(string $_type = "user")
    {
        return $_SESSION[$_type]["prenom"] . " " . $_SESSION[$_type]["nom"];
    }

    public static function getType(string $_type = "user")
    {
        return $_SESSION[$_type]["idType"];
    }

    public static function isConnect(string $_type = "user")
    {
        return (isset($_SESSION[$_type]["id"])) ? TRUE : FALSE;
    }

    public static function access(array $_type){
        return (in_array($_SESSION["user"]["idType"], $_type)) ? TRUE : FALSE;
    }

    public static function isEspaceControleurs(){
        return ($_SERVER['HTTP_HOST'] == DOMAIN_CONTROL) ? TRUE : FALSE;
    }

    public static function isEspaceSalaries(){
        return ($_SERVER['HTTP_HOST'] == DOMAIN_EVENTS) ? TRUE : FALSE;
    }

}
