<commit_before><?php

namespace User;

use ZfcBase\Module\AbstractModule;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\ApplicationInterface;

class Module extends AbstractModule
{
    /**
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     *
     * @param ModuleManager $moduleManager
     * @param ApplicationInterface $app
     */
    public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app)
    {
        $em = $app->getEventManager()->getSharedManager();
        $sm = $app->getServiceManager();

        $em->attach('ScnSocialAuth\Authentication\Adapter\HybridAuth', 'githubToLocalUser', function ($e) {
            $localUser = $e->getTarget();
            $userProfile = $e->getParam('userProfile');
            $nickname = substr(
                $userProfile->profileURL,
                (strrpos($userProfile->profileURL, "/") + 1)
            );
            $localUser->setUsername($nickname);
            $localUser->setPhotoUrl($userProfile->photoURL);
        });

        $em->attach('EdpGithub\Client', 'api', function ($e) use ($sm) {
            $hybridAuth = $sm->get('HybridAuth');
            $adapter = $hybridAuth->getAdapter('github');

            if ($adapter->isUserConnected()) {
                $token = $adapter->getAccessToken();
                $client = $e->getTarget();
                $client->authenticate('url_token', $token['access_token']);
            }
        });
    }

    public function getServiceConfig()
    {
        return array(
            'factories' => array(<commit_msg>gitHubToLocalUser event no longer exists in ScnSocialAuth module, attach listener on general registerViaProvider event with provider check<commit_after><?php

namespace User;

use ZfcBase\Module\AbstractModule;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\ApplicationInterface;

class Module extends AbstractModule
{
    /**
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     *
     * @param ModuleManager $moduleManager
     * @param ApplicationInterface $app
     */
    public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app)
    {
        $em = $app->getEventManager()->getSharedManager();
        $sm = $app->getServiceManager();

        $em->attach('ScnSocialAuth\Authentication\Adapter\HybridAuth', 'registerViaProvider', function ($e) {
            $provider = $e->getParam('provider');

            if ('github' !== $provider) {
                return;
            }

            $localUser = $e->getParam('user');
            $userProfile = $e->getParam('userProfile');
            $nickname = substr(
                $userProfile->profileURL,
                (strrpos($userProfile->profileURL, "/") + 1)
            );
            $localUser->setUsername($nickname);
            $localUser->setPhotoUrl($userProfile->photoURL);
        });

        $em->attach('EdpGithub\Client', 'api', function ($e) use ($sm) {
            $hybridAuth = $sm->get('HybridAuth');
            $adapter = $hybridAuth->getAdapter('github');

            if ($adapter->isUserConnected()) {
                $token = $adapter->getAccessToken();
                $client = $e->getTarget();
                $client->authenticate('url_token', $token['access_token']);
            }
        });
    }

    public function getServiceConfig()
    {
        return array(
            'factories' => array(
{'fraction_non_alphanumeric': 0.1391509433962264, 'fraction_numerical': 0.0005896226415094339, 'mean_word_length': 2.4272727272727272, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, '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': '5372550', 'n_tokens_mistral': 931, 'n_tokens_neox': 899, 'n_words': 161}