<commit_before><?php
/**
 * Github.php
 * A service for Github
 *
 * @author  <NAME> <<EMAIL>>
 * @link    http://www.michael-pratt.com/
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 */
namespace SimpleLifestream\Services;

class Github extends \SimpleLifestream\ServiceAdapter
{
    protected $url = 'https://github.com/%s.json';
    /**
     * Gets the data of the user and returns an array
     * with all the information.
     *
     * @return array
     */
    public function getApiData()
    {
        $response = $this->http->get(sprintf($this->url, $this->resource));
        $response = (array) json_decode($response, true);
        if (!empty($response))
            return array_filter(array_map(array($this, 'filterResponse'), $response));

        throw new \Exception('No entries found on ' . sprintf($this->url, $this->resource));
    }

    /**
     * Callback method that filters/translates the ApiResponse
     *
     * @param array $value
     * @return array
     */
    protected function filterResponse($value)
    {
        if (!in_array($value['type'], array('PushEvent', 'CreateEvent', 'GistEvent', 'WatchEvent', 'FollowEvent')))
            return ;

        // Store the username as resource
        $resource = $value['actor'];
        switch ($value['type'])
        {
            case 'CreateEvent':
            case 'PushEvent':

                /**<commit_msg>Minor bugfix in the Github Service<commit_after><?php
/**
 * Github.php
 * A service for Github
 *
 * @author  <NAME> <<EMAIL>>
 * @link    http://www.michael-pratt.com/
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 */
namespace SimpleLifestream\Services;

class Github extends \SimpleLifestream\ServiceAdapter
{
    protected $url = 'https://github.com/%s.json';
    /**
     * Gets the data of the user and returns an array
     * with all the information.
     *
     * @return array
     */
    public function getApiData()
    {
        $response = $this->http->get(sprintf($this->url, $this->resource));
        $response = (array) json_decode($response, true);
        if (!empty($response))
            return array_filter(array_map(array($this, 'filterResponse'), $response));

        throw new \Exception('No entries found on ' . sprintf($this->url, $this->resource));
    }

    /**
     * Callback method that filters/translates the ApiResponse
     *
     * @param array $value
     * @return array
     */
    protected function filterResponse($value)
    {
        if (empty($value['type']) || !in_array($value['type'], array('PushEvent', 'CreateEvent', 'GistEvent', 'WatchEvent', 'FollowEvent')))
            return ;

        // Store the username as resource
        $resource = $value['actor'];
        switch ($value['type'])
        {
            case 'CreateEvent':
            case 'PushEvent':

                /**
{'fraction_non_alphanumeric': 0.13863031914893617, 'fraction_numerical': 0.0, 'mean_word_length': 2.5316901408450705, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6425562', 'n_tokens_mistral': 837, 'n_tokens_neox': 834, 'n_words': 234}