<commit_before><?php namespace NpmWeb\GitApiClient;

use Bitbucket\API\Repositories;

class BitbucketApiClient implements GitApiClientInterface {

    protected $repositoriesClient;

    public function __construct( Repositories $repositoriesClient )
    {
        $this->repositoriesClient = $repositoriesClient;
    }

    public function getReposOwnedBy( $account, $language = null )
    {
        $response = $this->repositoriesClient->all('npmweb');
        $this->handleErrorResponse($response);
        $repoNames = $this->extractRepoNames( $response );

        while( $response = $this->repositoriesClient->next() ) {
            $this->handleErrorResponse($response);
            $repoNames = array_merge( $repoNames, $this->extractRepoNames( $response, $language ) );
        }

        return $repoNames;
    }

    protected function handleErrorResponse( $response )
    {
        if( 200 != $response->getStatusCode() ) {
            var_dump($response);
            throw new \Exception('Could not connect to Bitbucket API. '.$response->getStatusCode().': '.$response->getReasonPhrase());
        }
    }

    protected function extractRepoNames( $response, $language = null )
    {
        $responseObj = json_decode($response->getContent());
        $repos = $responseObj->values;
        if( $language ) {
            $repos = array_filter( $repos, function($repo) use($language) {
                return !isset($repo->language) || $language == $repo->language;
            });
        }
        $repoNames = array_map( function($repo) {
            return $repo->name;
        }, $repos );
        return $repoNames;
    }

}<commit_msg>returns repo url, not just name<commit_after><?php namespace NpmWeb\GitApiClient;

use Bitbucket\API\Repositories;

class BitbucketApiClient implements GitApiClientInterface {

    protected $repositoriesClient;

    public function __construct( Repositories $repositoriesClient )
    {
        $this->repositoriesClient = $repositoriesClient;
    }

    public function getReposOwnedBy( $account, $language = null )
    {
        $response = $this->repositoriesClient->all('npmweb');
        $this->handleErrorResponse($response);
        $repoNames = $this->extractRepos( $response );

        while( $response = $this->repositoriesClient->next() ) {
            $this->handleErrorResponse($response);
            $repoNames = array_merge( $repoNames, $this->extractRepos( $response, $language ) );
        }

        return $repoNames;
    }

    protected function handleErrorResponse( $response )
    {
        if( 200 != $response->getStatusCode() ) {
            throw new \Exception('Could not connect to Bitbucket API. '.$response->getStatusCode().': '.$response->getReasonPhrase());
        }
    }

    protected function extractRepos( $response, $language = null )
    {
        $responseObj = json_decode($response->getContent());
        $repos = $responseObj->values;
        if( $language ) {
            $repos = array_filter( $repos, function($repo) use($language) {
                return !isset($repo->language) || $language == $repo->language;
            });
        }
        $repos = array_map( function($repo) {
            return (object)array(
                'name' => $repo->name,
                'url' => $repo->links->clone[1]->href,
            );
        }, $repos );
        return $repos;
    }

}
{'fraction_non_alphanumeric': 0.1345926800472255, 'fraction_numerical': 0.002066115702479339, 'mean_word_length': 2.593849416755037, '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': '5555311', 'n_tokens_mistral': 954, 'n_tokens_neox': 909, 'n_words': 186}