<commit_before><?php
/*
    Condorcet PHP Class, with Schulze Methods and others !

    By <NAME> - MIT LICENSE (Please read LICENSE.txt)
    https://github.com/julien-boudry/Condorcet
*/
declare(strict_types=1);

namespace Condorcet;

use Condorcet\CondorcetException;
use Condorcet\Election;

// Generic for Candidate & Vote Class
trait Linkable
{
    private $_link = [];

    public function __clone ()
    {
        $this->destroyAllLink();
    }

    public function __debugInfo () : array
    {
        $var = get_object_vars($this);

        foreach ($var['_link'] as $key => $oneLink)
        {
            $var['_link'][$key] = 'Object '.get_class($oneLink).' => '.sha1(spl_object_hash($oneLink));
        }

        return $var;
    }

    public function haveLink (Election &$election) : bool
    {
        return in_array($election, $this->_link, true);
    }

    public function countLinks () : int
    {
        return count($this->_link);
    }

    public function getLinks ()
    {
        return (!empty($this->_link)) ? $this->_link : NULL;
    }

    // Internal
        # Dot not Overloading ! Do not Use !

    public function registerLink (Election &$election)
    {
        if (array_search($election, $this->_link, true) === false)
            { $this->_link[] = $election; }
        else
            { throw new CondorcetException; }
    }

    public function destroyLink (Election &$election) : bool
    {
        $destroyKey = array_search($election, $this->_link, true);

        if ($destroyKey !== false)
        {
            unset($this->_link[$destroyKey]);
            return true;
        }
        else
            { throw new CondorcetException; }
    }

    protected function destroyAllLink ()
    {
        $this->_link = [];
    }
}<commit_msg>Disabling DebugInfo cause of strange reference bugs.<commit_after><?php
/*
    Condorcet PHP Class, with Schulze Methods and others !

    By <NAME> - MIT LICENSE (Please read LICENSE.txt)
    https://github.com/julien-boudry/Condorcet
*/
declare(strict_types=1);

namespace Condorcet;

use Condorcet\CondorcetException;
use Condorcet\Election;

// Generic for Candidate & Vote Class
trait Linkable
{
    private $_link = [];

    public function __clone ()
    {
        $this->destroyAllLink();
    }

    /*
    public function __debugInfo () : array
    {
        $var = get_object_vars($this);

        foreach ($var['_link'] as $key => $oneLink)
        {
            $var['_link'][$key] = 'Object '.get_class($oneLink).' => '.sha1(spl_object_hash($oneLink));
        }

        return $var;
    }
    */

    public function haveLink (Election $election) : bool
    {
        return in_array($election, $this->_link, true);
    }

    public function countLinks () : int
    {
        return count($this->_link);
    }

    public function getLinks ()
    {
        return (!empty($this->_link)) ? $this->_link : NULL;
    }

    // Internal
        # Dot not Overloading ! Do not Use !

    public function registerLink (Election $election)
    {
        if (array_search($election, $this->_link, true) === false)
            { $this->_link[] = $election; }
        else
            { throw new CondorcetException; }
    }

    public function destroyLink (Election $election) : bool
    {
        $destroyKey = array_search($election, $this->_link, true);

        if ($destroyKey !== false)
        {
            unset($this->_link[$destroyKey]);
            return true;
        }
        else
            { throw new CondorcetException; }
    }

    protected function destroyAllLink ()
    {
        $this->_link = [];
    }
}
{'fraction_non_alphanumeric': 0.13175303197353913, 'fraction_numerical': 0.0011025358324145535, 'mean_word_length': 2.177758318739054, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '1825424', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1059, 'n_words': 254}