<commit_before><?php

namespace Lonestar\Bundle\OpenCfpBundle;

use Sculpin\Core\Source\DataSourceInterface;
use Dflydev\DotAccessConfiguration\ConfigurationInterface;
use Dflydev\Symfony\FinderFactory\FinderFactory;
use Dflydev\Symfony\FinderFactory\FinderFactoryInterface;
use dflydev\util\antPathMatcher\AntPathMatcher;
use Sculpin\Core\SiteConfiguration\SiteConfigurationFactory;
use Sculpin\Core\Source\SourceSet;
use Sculpin\Core\Source\MemorySource;

class OpenCfpDataSource implements DataSourceInterface {

    /**
     * Constructor.
     *
     * @param ConfigurationInterface   $siteConfiguration        Site Configuration
     * @param SiteConfigurationFactory $siteConfigurationFactory Site Configuration Factory
     * @param FinderFactoryInterface   $finderFactory            Finder Factory
     * @param AntPathMatcher           $matcher                  Matcher
     */
    public function __construct(
        ConfigurationInterface $siteConfiguration,
        SiteConfigurationFactory $siteConfigurationFactory,
        FinderFactoryInterface $finderFactory = null,
        AntPathMatcher $matcher = null
    ) {
        $this->siteConfiguration = $siteConfiguration;
        $this->siteConfigurationFactory = $siteConfigurationFactory;
        $this->finderFactory = $finderFactory ?: new FinderFactory;
        $this->matcher = $matcher ?: new AntPathMatcher;
        $this->sinceTime = '1970-01-01T00:00:00Z';
    }

    public function dataSourceId() {
        return "OpenCfpDataSource:URLHERE";
    }

    public function refresh(SourceSet $sourceSet) {
        $sinceTimeLast = $this->sinceTime;
        $this->sinceTime = date('c');

        $mockData = [
            [
                'name' => '<NAME>',
                'country' => 'USA',
                'twitter' => '@dcousineau',
            ],
            [
                'name' => '<NAME>',
                'country' => 'USA',
                'twitter' => '@dcousineau',
            ]
        ];

        $newConfig = $this->siteConfigurationFactory->create();
        $newConfig->set('opencfp', [
            'speakers' => $mockData
        ]);

        $this->siteConfiguration->import($newConfig);
    }
}<commit_msg>Get rid of mock data for real API request for sponsors data source<commit_after><?php

namespace Lonestar\Bundle\OpenCfpBundle;

use Sculpin\Core\Source\DataSourceInterface;
use Dflydev\DotAccessConfiguration\ConfigurationInterface;
use Dflydev\Symfony\FinderFactory\FinderFactory;
use Dflydev\Symfony\FinderFactory\FinderFactoryInterface;
use dflydev\util\antPathMatcher\AntPathMatcher;
use Sculpin\Core\SiteConfiguration\SiteConfigurationFactory;
use Sculpin\Core\Source\SourceSet;
use Sculpin\Core\Source\MemorySource;

class OpenCfpDataSource implements DataSourceInterface {

    /**
     * Constructor.
     *
     * @param ConfigurationInterface   $siteConfiguration        Site Configuration
     * @param SiteConfigurationFactory $siteConfigurationFactory Site Configuration Factory
     * @param FinderFactoryInterface   $finderFactory            Finder Factory
     * @param AntPathMatcher           $matcher                  Matcher
     */
    public function __construct(
        ConfigurationInterface $siteConfiguration,
        SiteConfigurationFactory $siteConfigurationFactory,
        FinderFactoryInterface $finderFactory = null,
        AntPathMatcher $matcher = null
    ) {
        $this->siteConfiguration = $siteConfiguration;
        $this->siteConfigurationFactory = $siteConfigurationFactory;
        $this->finderFactory = $finderFactory ?: new FinderFactory;
        $this->matcher = $matcher ?: new AntPathMatcher;
        $this->sinceTime = '1970-01-01T00:00:00Z';
        $this->baseUrl = 'http://api.lonestarphp.com';
    }

    public function dataSourceId() {
        return "OpenCfpDataSource:URLHERE";
    }

    public function refresh(SourceSet $sourceSet) {
        $sinceTimeLast = $this->sinceTime;
        $this->sinceTime = date('c');

        $newConfig = $this->siteConfigurationFactory->create();
        $newConfig->set('opencfp', [
            'sponsors' => $this->getSponsors(),
        ]);

        $this->siteConfiguration->import($newConfig);
    }

    /**
     * Get Sponsors List from API
     * @return array
     */
    public function getSponsors()
    {
        return (new \Guzzle\Http\Client($this->baseUrl))
            ->get('/sponsors')
            ->send()
            ->json();
    }
}
{'fraction_non_alphanumeric': 0.10421335723890632, 'fraction_numerical': 0.0062752129090094125, 'mean_word_length': 2.785411365564037, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 43, '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': '4226284', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1167, 'n_words': 223}