<commit_before><?php

namespace Bolt\Storage\Field\Type;

use Bolt\Storage\QuerySet;
use Cocur\Slugify\Slugify;

/**
 * Trait for TaxonomyType logic.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
trait TaxonomyTypeTrait
{
    /**
     * Get existing taxonomy records.
     *
     * @param mixed $entity
     *
     * @return array
     */
    public function getExisting($entity)
    {
        $field = $this->mapping['fieldname'];
        $target = $this->mapping['target'];
<commit_msg>Getter for associative array of ['slug' => 'name'] for taxonomy values<commit_after><?php

namespace Bolt\Storage\Field\Type;

use Bolt\Storage\QuerySet;
use Cocur\Slugify\Slugify;

/**
 * Trait for TaxonomyType logic.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
trait TaxonomyTypeTrait
{
    /**
     * Get an associative array of ['slug' => 'name'] for taxonomy values.
     *
     * @param string $taxName
     * @param array  $data
     *
     * @return array
     */
    public function getTaxonomyValues($taxName, array $data)
    {
        $taxonomy = [];
        $slugs = explode(',', $data[$taxName . '_slugs']);
        $names = explode(',', $data[$taxName]);
        foreach ($slugs as $index => $value) {
            $taxonomy[$value] = $names[$index];
        }

        return $taxonomy;
    }

    /**
     * Get existing taxonomy records.
     *
     * @param mixed $entity
     *
     * @return array
     */
    public function getExisting($entity)
    {
        $field = $this->mapping['fieldname'];
        $target = $this->mapping['target'];

{'fraction_non_alphanumeric': 0.1581600504095778, 'fraction_numerical': 0.0, 'mean_word_length': 2.49010989010989, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 22, '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': '6977267', 'n_tokens_mistral': 512, 'n_tokens_neox': 514, 'n_words': 119}