<commit_before><?php
namespace Tonis\OAuth2\Storage;

use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\AuthCodeEntity;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Storage\SessionInterface;
use Tonis\OAuth2\Entity;
use Tonis\OAuth2\Repository;

class Session implements SessionInterface
{
    use StorageTrait;

    /** @var Repository\Session */
    private $sessionRepository;

    /**
     * @param Repository\Session $sessionRepository
     * @param Repository\Scope $scopeRepository
     */
    public function __construct(
        Repository\Session $sessionRepository,
        Repository\Scope $scopeRepository
    ) {
        $this->sessionRepository = $sessionRepository;
        $this->scopeRepository   = $scopeRepository;
    }

    /**
     * {@inheritdoc}
     */
    public function getByAccessToken(AccessTokenEntity $accessToken)
    {
        $session = $this
            ->sessionRepository
            ->findOneByAccessToken($accessToken->getId());

        $leagueSession = new SessionEntity($this->server);
        $leagueSession->setId($session->getId());
        $leagueSession->setOwner($session->getOwnerType(), $session->getOwnerId());

        return $leagueSession;
    }

    /**
     * {@inheritDoc}
     */
    public function getByAuthCode(AuthCodeEntity $authCode)
    {
        $session = $this
            ->sessionRepository
            ->findOneByAuthCode($authCode->getId());

        $leagueSession = new SessionEntity($this->server);
        $leagueSession->setId($session->getId());
        $leagueSession->setOwner($session->getOwnerType(), $session->getOwnerId());

        return $leagueSession;
    }

    /**
     * {@inheritDoc}
     */
    public function getScopes(SessionEntity $leagueSession)
    {<commit_msg>Bug fix for missing session identifier<commit_after><?php
namespace Tonis\OAuth2\Storage;

use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\AuthCodeEntity;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Storage\SessionInterface;
use Tonis\OAuth2\Entity;
use Tonis\OAuth2\Repository;

class Session implements SessionInterface
{
    use StorageTrait;

    /** @var Repository\Session */
    private $sessionRepository;

    /**
     * @param Repository\Session $sessionRepository
     * @param Repository\Scope $scopeRepository
     */
    public function __construct(
        Repository\Session $sessionRepository,
        Repository\Scope $scopeRepository
    ) {
        $this->sessionRepository = $sessionRepository;
        $this->scopeRepository   = $scopeRepository;
    }

    /**
     * {@inheritdoc}
     */
    public function getByAccessToken(AccessTokenEntity $accessToken)
    {
        $session = $this
            ->sessionRepository
            ->findOneByAccessToken($accessToken->getId());

        $leagueSession = new SessionEntity($this->server);
        $leagueSession->setId($session->getId());
        $leagueSession->setOwner($session->getOwnerType(), $session->getOwnerId());

        return $leagueSession;
    }

    /**
     * {@inheritDoc}
     */
    public function getByAuthCode(AuthCodeEntity $authCode)
    {
        $session = $this
            ->sessionRepository
            ->findOneByAuthCode($authCode->getId());

        $leagueSession = new SessionEntity($this->server);
        $leagueSession->setId($session->getId());
        $leagueSession->setOwner($session->getOwnerType(), $session->getOwnerId());

        return $leagueSession;
    }

    /**
     * {@inheritDoc}
     */
    public function getScopes(SessionEntity $leagueSession)
    {
        if (null === $leagueSession->getId()) {
            return [];
        }

{'fraction_non_alphanumeric': 0.12412177985948478, 'fraction_numerical': 0.004163413999479573, 'mean_word_length': 2.9628865979381445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '2724185', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1043, 'n_words': 175}