<commit_before><?php
/**
 * Created by IntelliJ IDEA.
 * User: stopka
 * Date: 13.10.17
 * Time: 12:19
 */

namespace Stopka\OpenviduPhpClient;


use Stopka\OpenviduPhpClient\Recording\Recording;
use Stopka\OpenviduPhpClient\Recording\RecordingLayoutEnum;
use Stopka\OpenviduPhpClient\Recording\RecordingOutputModeEnum;
use Stopka\OpenviduPhpClient\Recording\RecordingProperties;
use Stopka\OpenviduPhpClient\Recording\RecordingPropertiesBuilder;
use Stopka\OpenviduPhpClient\Rest\RestClient;
use Stopka\OpenviduPhpClient\Rest\RestClientException;
use Stopka\OpenviduPhpClient\Session\Session;
use Stopka\OpenviduPhpClient\Session\SessionProperties;

class OpenVidu
{
    protected const HTTP_USERNAME = "OPENVIDUAPP";

    const SESSIONS_URL = "api/sessions";
    const TOKENS_URL = "api/tokens";
    const RECORDINGS_URL = "api/recordings";
    const RECORDINGS_START_URL = "api/recordings/start";
    const RECORDINGS_STOP_URL = "api/recordings/stop";

    /** @var  string */
    protected $urlOpenViduServer;

    /** @var string */
    protected $secret;

    /** @var RestClient */
    protected $restClient;

    /** @var Session[] */
    protected $activeSessions = [];

    /**
     * OpenVidu constructor.
     * @param string $urlOpenViduServer
     * @param string $secret
     */
    public function __construct(string $urlOpenViduServer, string $secret)
    {
        $this->secret = $secret;
        $this->urlOpenViduServer = $urlOpenViduServer;
        $this->restClient = $this->buildRestClient();
    }

    /**
     * @param SessionProperties|null $properties
     * @return Session
     * @throws OpenViduException
     */
    public function createSession(?SessionProperties $properties = null): Session
    {
        $session = Session::createFromProperties($this->restClient, $properties);
        $this->activeSessions[$session->getSessionId()] = $session;
        return $session;<commit_msg>Added direct session creation from openvidu<commit_after><?php
/**
 * Created by IntelliJ IDEA.
 * User: stopka
 * Date: 13.10.17
 * Time: 12:19
 */

namespace Stopka\OpenviduPhpClient;


use Stopka\OpenviduPhpClient\Recording\Recording;
use Stopka\OpenviduPhpClient\Recording\RecordingLayoutEnum;
use Stopka\OpenviduPhpClient\Recording\RecordingOutputModeEnum;
use Stopka\OpenviduPhpClient\Recording\RecordingProperties;
use Stopka\OpenviduPhpClient\Recording\RecordingPropertiesBuilder;
use Stopka\OpenviduPhpClient\Rest\RestClient;
use Stopka\OpenviduPhpClient\Rest\RestClientException;
use Stopka\OpenviduPhpClient\Session\Session;
use Stopka\OpenviduPhpClient\Session\SessionProperties;

class OpenVidu
{
    protected const HTTP_USERNAME = "OPENVIDUAPP";

    const SESSIONS_URL = "api/sessions";
    const TOKENS_URL = "api/tokens";
    const RECORDINGS_URL = "api/recordings";
    const RECORDINGS_START_URL = "api/recordings/start";
    const RECORDINGS_STOP_URL = "api/recordings/stop";

    /** @var  string */
    protected $urlOpenViduServer;

    /** @var string */
    protected $secret;

    /** @var RestClient */
    protected $restClient;

    /** @var Session[] */
    protected $activeSessions = [];

    /**
     * OpenVidu constructor.
     * @param string $urlOpenViduServer
     * @param string $secret
     */
    public function __construct(string $urlOpenViduServer, string $secret)
    {
        $this->secret = $secret;
        $this->urlOpenViduServer = $urlOpenViduServer;
        $this->restClient = $this->buildRestClient();
    }

    /**
     * @param SessionProperties|null $properties
     * @return Session
     * @throws OpenViduException
     */
    public function createSession(?SessionProperties $properties = null): Session
    {
        $session = Session::createFromProperties($this->restClient, $properties);
        $this->activeSessions[$session->getSessionId()] = $session;
        return $session;
    }

    /**
     * @param SessionProperties|null $properties
     * @return Session|null
     */
    public function createSessionFromDataArray(array $data): ?Session
    {
        try {
            $session = Session::createFromArray($this->restClient, $data);
            $this->activeSessions[$session->getSessionId()] = $session;
            return $session;
        }catch (EnumException $e){
            return null;
        }
{'fraction_non_alphanumeric': 0.11338289962825279, 'fraction_numerical': 0.004646840148698885, 'mean_word_length': 3.5603813559322033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2481526', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1320, 'n_words': 243}