<commit_before><?php

namespace WPApi;

use Goutte\Client;
use WPApi\Interfaces\ApiInterface;

abstract class AbstractApiCall implements ApiInterface
{
    /**
     * Goutte Client.
     *
     * @var Client
     */
    protected $client;

    public function __construct()
    {
        $this->client = new Client();
    }

    protected function makeApiCall(array $body)
    {
        $this->client->request('POST', $this->getUri(), $body);
        $content = $this->client->getResponse()->getContent();

        return unserialize($content);
    }

    public function author($name)
    {
        $arguments = [
            'author' => $name,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function browse($type)
    {
        $arguments = [
            'browse' => $type,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function search($keywords)
    {
        $arguments = [
            'search' => $keywords,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function slug($slug)
    {
        echo $this->getAction('information');
        $arguments = [
            'slug' => $slug,
        ];
        $body = [
            'action' => $this->getAction('information'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function tag($tag)
    {
        $arguments = [
            'tag' => $tag,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function getAction($type)
    {
        if ($type == 'information') {
            return rtrim($this->getType(), 's')."_{$type}";
        }

        return "{$type}_{$this->getType()}";
    }

    public function getUri()
    {
        return "http://api.wordpress.org/{$this->getType()}/info/1.0/";
    }

    abstract protected function getType();
}
<commit_msg>remove unused echo<commit_after><?php

namespace WPApi;

use Goutte\Client;
use WPApi\Interfaces\ApiInterface;

abstract class AbstractApiCall implements ApiInterface
{
    /**
     * Goutte Client.
     *
     * @var Client
     */
    protected $client;

    public function __construct()
    {
        $this->client = new Client();
    }

    protected function makeApiCall(array $body)
    {
        $this->client->request('POST', $this->getUri(), $body);
        $content = $this->client->getResponse()->getContent();

        return unserialize($content);
    }

    public function author($name)
    {
        $arguments = [
            'author' => $name,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function browse($type)
    {
        $arguments = [
            'browse' => $type,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function search($keywords)
    {
        $arguments = [
            'search' => $keywords,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function slug($slug)
    {
        $arguments = [
            'slug' => $slug,
        ];
        $body = [
            'action' => $this->getAction('information'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function tag($tag)
    {
        $arguments = [
            'tag' => $tag,
        ];
        $body = [
            'action' => $this->getAction('query'),
            'request' => serialize((object) $arguments),
        ];

        return $this->makeApiCall($body);
    }

    public function getAction($type)
    {
        if ($type == 'information') {
            return rtrim($this->getType(), 's')."_{$type}";
        }

        return "{$type}_{$this->getType()}";
    }

    public function getUri()
    {
        return "http://api.wordpress.org/{$this->getType()}/info/1.0/";
    }

    abstract protected function getType();
}

{'fraction_non_alphanumeric': 0.1664940981569683, 'fraction_numerical': 0.0008283288465520812, 'mean_word_length': 1.811408614668219, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 74, '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': '6239083', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1387, 'n_words': 254}