<commit_before><?php

namespace Transit\WebBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use FOS\UserBundle\Model\User;

/**
 * @author <NAME> <<EMAIL>>
 */
class UserAccount extends User
{
    /**
     * @var mixed
     */
    protected $id;

    /**
     * @var Project[]|Collection
     */
    protected $projects;

    /**
     * @var OauthAccount[]|Collection
     */
    protected $oauthAccounts;

    /**
     * {@inheritdoc}
     */
    public function __construct()
    {
        parent::__construct();

        $this->projects = new ArrayCollection();
        $this->oauthAccounts = new ArrayCollection();
    }

    /**
     * @return Collection|Project[]
     */
    public function getProjects()
    {
        return $this->projects;
    }

    /**
     * @param Project $project
     *
     * @return $this
     */
    public function addProject(Project $project)
    {
        $this->projects[] = $project;

        return $this;
    }

    /**
     * @param Project $project
     *
     * @return $this
     */
    public function removeProject(Project $project)
    {
        $this->projects->removeElement($project);

        return $this;
    }

    /**
     * @return OauthAccount[]|Collection
     */
    public function getOauthAccounts()
    {
        return $this->oauthAccounts;
    }

    /**
     * @param OauthAccount $oauthAccount
     *
     * @return $this
     */
    public function addOauthAccount(OauthAccount $oauthAccount)
    {
        $this->oauthAccounts[] = $oauthAccount;

        return $this;
    }

    /**
     * @param OauthAccount $oauthAccount
     *
     * @return $this
     */
    public function removeOauthAccount(OauthAccount $oauthAccount)
    {
        $this->oauthAccounts->removeElement($oauthAccount);

        return $this;
    }

    /**
     * @todo If the same GitHub OAuth account is added twice to a user as a result of renewed permissions, overwrite the previous one.
     *
     * @return null|OauthAccount
     */
    public function getGithubOauthAccount()
    {
        $githubOauth = null;

        foreach ($this->getOauthAccounts() as $oauth) {
            if ("github" === $oauth->getProvider()) {
                $githubOauth = $oauth;
            }
        }

        return $githubOauth;
    }
}
<commit_msg>Add missing assignment of user to OAuth account<commit_after><?php

namespace Transit\WebBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use FOS\UserBundle\Model\User;

/**
 * @author <NAME> <<EMAIL>>
 */
class UserAccount extends User
{
    /**
     * @var mixed
     */
    protected $id;

    /**
     * @var Project[]|Collection
     */
    protected $projects;

    /**
     * @var OauthAccount[]|Collection
     */
    protected $oauthAccounts;

    /**
     * {@inheritdoc}
     */
    public function __construct()
    {
        parent::__construct();

        $this->projects = new ArrayCollection();
        $this->oauthAccounts = new ArrayCollection();
    }

    /**
     * @return Collection|Project[]
     */
    public function getProjects()
    {
        return $this->projects;
    }

    /**
     * @param Project $project
     *
     * @return $this
     */
    public function addProject(Project $project)
    {
        $this->projects[] = $project;

        return $this;
    }

    /**
     * @param Project $project
     *
     * @return $this
     */
    public function removeProject(Project $project)
    {
        $this->projects->removeElement($project);

        return $this;
    }

    /**
     * @return OauthAccount[]|Collection
     */
    public function getOauthAccounts()
    {
        return $this->oauthAccounts;
    }

    /**
     * @param OauthAccount $oauthAccount
     *
     * @return $this
     */
    public function addOauthAccount(OauthAccount $oauthAccount)
    {
        $oauthAccount->setUserAccount($this);

        $this->oauthAccounts[] = $oauthAccount;

        return $this;
    }

    /**
     * @param OauthAccount $oauthAccount
     *
     * @return $this
     */
    public function removeOauthAccount(OauthAccount $oauthAccount)
    {
        $this->oauthAccounts->removeElement($oauthAccount);

        return $this;
    }

    /**
     * @todo If the same GitHub OAuth account is added twice to a user as a result of renewed permissions, overwrite the previous one.
     *
     * @return null|OauthAccount
     */
    public function getGithubOauthAccount()
    {
        $githubOauth = null;

        foreach ($this->getOauthAccounts() as $oauth) {
            if ("github" === $oauth->getProvider()) {
                $githubOauth = $oauth;
            }
        }

        return $githubOauth;
    }
}

{'fraction_non_alphanumeric': 0.1253925057567511, 'fraction_numerical': 0.0, 'mean_word_length': 2.0375079465988555, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 34, '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': '517525', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1391, 'n_words': 296}