<commit_before><?php

namespace Joe\Content\Scraper;

use Joe\Connection;
use Joe\Http\Client;
use Joe\User;
use Joe\User\ClientTrait;
use simplehtmldom_1_5\simple_html_dom;
use simplehtmldom_1_5\simple_html_dom_node;

class SubscriptionsScraper extends AbstractScraper
{
    use ClientTrait;
    use PrepareableTrait;

    /** @var  User */
    protected $id;

    public function __construct($id, Client $client)
    {
        parent::__construct($id, $client);
        $this->prepare();
    }

    public function getAddress()
    {
        return Connection::ADDRESS . '/bojownik/' . $this->id->nickName() . '/subskrypcje';
    }

    protected function contentHtml(simple_html_dom $fullHtml = null)
    {
        $node = $fullHtml->find('#userProfileContent');
        return $node[0] ?: null;
    }

    public function blogSubscriptions()
    {
        $collecion = new \ArrayObject;
        /** @var simple_html_dom_node $node */
        $node = $this->content->find('h2', 0);
        if ($node && $node->text() == 'Subskrybenci bloga') {
            /** @var simple_html_dom_node $sibling */
            $sibling = $node->nextSibling();
            foreach ($sibling->childNodes() as $child) {
                if ($child->class == 'avatar') {
                    $collecion->append(new User(trim($child->text())));
                }
            }
        }

        return $collecion;
    }
}
<commit_msg>refactoring; method extracted to more generic<commit_after><?php

namespace Joe\Content\Scraper;

use Joe\Connection;
use Joe\Http\Client;
use Joe\User;
use Joe\User\ClientTrait;
use simplehtmldom_1_5\simple_html_dom;
use simplehtmldom_1_5\simple_html_dom_node;

class SubscriptionsScraper extends AbstractScraper
{
    use ClientTrait;
    use PrepareableTrait;

    /** @var  User */
    protected $id;

    public function __construct($id, Client $client)
    {
        parent::__construct($id, $client);
        $this->prepare();
    }

    public function getAddress()
    {
        return Connection::ADDRESS . '/bojownik/' . $this->id->nickName() . '/subskrypcje';
    }

    protected function contentHtml(simple_html_dom $fullHtml = null)
    {
        $node = $fullHtml->find('#userProfileContent');
        return $node[0] ?: null;
    }

    public function blogSubscriptions()
    {
        return $this->getUsersFromSection('Subskrybenci bloga', 0);
    }

    /**
     * @param $header
     * @param $index
     * @return mixed
     */
    protected function getUsersFromSection($header, $index)
    {
        $collecion = new \ArrayObject;
        /** @var simple_html_dom_node $node */
        $node = $this->content->find('h2', $index);
        if ($node && $node->text() == $header) {
            /** @var simple_html_dom_node $sibling */
            $sibling = $node->nextSibling();
            foreach ($sibling->childNodes() as $child) {
                if ($child->class == 'avatar') {
                    $collecion->append(new User(trim($child->text())));
                }
            }
        }

        return $collecion;
    }
}

{'fraction_non_alphanumeric': 0.1392775789131142, 'fraction_numerical': 0.004555808656036446, 'mean_word_length': 2.3854625550660793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, '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': '2880379', 'n_tokens_mistral': 982, 'n_tokens_neox': 962, 'n_words': 190}