<commit_before><?php
abstract class AbstractCommand
{
    protected $config;
    
    public function __construct(Config $config)
    {
        $this->config = $config;
    }
    
    protected function out($str = null)
    {
        echo $str;
    }
    
    protected function outln($str = null)
    {
        $this->out($str . PHP_EOL);
    }
    
    protected function shell($cmd, &$output = null, &$return = null)
    {
        $cmd = str_replace('; ', ';\\' . PHP_EOL, $cmd);
        $this->outln($cmd);
        $output = null;
        $result = exec($cmd, $output, $return);
        foreach ($output as $line) {
            $this->outln($line);
        }
        return $result;
    }
    
    protected function api($method, $path, $body = null)
    {
        $github_auth = $this->config->github_user
                     . ':'
                     . $this->config->github_token;
                     
        $api = "https://{$github_auth}@api.github.com";
        $url = $api . $path;
        $context = stream_context_create([
            'http' => [
                'method' => $method,
                'header' => implode("\r\n", [
                    'User-Agent: php/5.4',
                    'Accept: application/json',
                    'Content-Type: application/json',
                ]),
                'content' => $body,
            ],
        ]);
        $json = file_get_contents($url, FALSE, $context);
        $data = json_decode($json);
        return $data;
    }
    
    protected function isReadableFile($file)
    {
        return file_exists($file) && is_readable($file);
    }
    
    protected function apiGetRepos()
    {
        $data = $this->api('GET', '/orgs/auraphp/repos');
        $repos = [];
        foreach ($data as $repo) {
            $repos[$repo->name] = $repo;
        }
        ksort($repos);
        return $repos;
    }
    
    protected function apiGetTags($repo)
    {
        $data = $this->api('GET', "/repos/auraphp/$repo/tags");
        $tags = [];
        foreach ($data as $tag) {
            $tags[] = $tag->name;
        }
        usort($tags, 'version_compare');
        return $tags;
    }
    
    protected function apiGetIssues($name)<commit_msg>'orgs' does not show all repos for some reason<commit_after><?php
abstract class AbstractCommand
{
    protected $config;
    
    public function __construct(Config $config)
    {
        $this->config = $config;
    }
    
    protected function out($str = null)
    {
        echo $str;
    }
    
    protected function outln($str = null)
    {
        $this->out($str . PHP_EOL);
    }
    
    protected function shell($cmd, &$output = null, &$return = null)
    {
        $cmd = str_replace('; ', ';\\' . PHP_EOL, $cmd);
        $this->outln($cmd);
        $output = null;
        $result = exec($cmd, $output, $return);
        foreach ($output as $line) {
            $this->outln($line);
        }
        return $result;
    }
    
    protected function api($method, $path, $body = null)
    {
        $github_auth = $this->config->github_user
                     . ':'
                     . $this->config->github_token;
                     
        $api = "https://{$github_auth}@api.github.com";
        $url = $api . $path;
        $context = stream_context_create([
            'http' => [
                'method' => $method,
                'header' => implode("\r\n", [
                    'User-Agent: php/5.4',
                    'Accept: application/json',
                    'Content-Type: application/json',
                ]),
                'content' => $body,
            ],
        ]);
        $json = file_get_contents($url, FALSE, $context);
        $data = json_decode($json);
        return $data;
    }
    
    protected function isReadableFile($file)
    {
        return file_exists($file) && is_readable($file);
    }
    
    protected function apiGetRepos()
    {
        $data = $this->api('GET', '/users/auraphp/repos');
        $repos = [];
        foreach ($data as $repo) {
            $repos[$repo->name] = $repo;
        }
        ksort($repos);
        return $repos;
    }
    
    protected function apiGetTags($repo)
    {
        $data = $this->api('GET', "/repos/auraphp/$repo/tags");
        $tags = [];
        foreach ($data as $tag) {
            $tags[] = $tag->name;
        }
        usort($tags, 'version_compare');
        return $tags;
    }
    
    protected function apiGetIssues($name)
{'fraction_non_alphanumeric': 0.15357142857142858, 'fraction_numerical': 0.0008928571428571428, 'mean_word_length': 1.5503699487763232, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 2, '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': '613455', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1322, 'n_words': 263}