<commit_before><?php
namespace Bolt\Storage\Field\Type;

use Bolt\Storage\EntityManager;
use Bolt\Storage\QuerySet;
use Doctrine\DBAL\Types\Type;

/**
 * This is one of a suite of basic Bolt field transformers that handles
 * the lifecycle of a field from pre-query to persist.
 *
 * @author <NAME> <<EMAIL>>
 */
class ListTypeBase extends FieldTypeBase
{
    /**
     * {@inheritdoc}
     */
    public function persist(QuerySet $queries, $entity, EntityManager $em = null)
    {
        $key = $this->mapping['fieldname'];
        $value = $entity->get($key);

        if ($value !== null && $this->isJson($value)) {
            $value = json_decode($value, true);
        }

        // Remove elements that are not important for storage.
        foreach ($value as &$v) {
            unset($v['id']);
            unset($v['order']);
            unset($v['progress']);
            unset($v['element']);
        }
        $entity->set($key, $value);
<commit_msg>Don't check value if null<commit_after><?php
namespace Bolt\Storage\Field\Type;

use Bolt\Storage\EntityManager;
use Bolt\Storage\QuerySet;
use Doctrine\DBAL\Types\Type;

/**
 * This is one of a suite of basic Bolt field transformers that handles
 * the lifecycle of a field from pre-query to persist.
 *
 * @author <NAME> <<EMAIL>>
 */
class ListTypeBase extends FieldTypeBase
{
    /**
     * {@inheritdoc}
     */
    public function persist(QuerySet $queries, $entity, EntityManager $em = null)
    {
        $key = $this->mapping['fieldname'];
        $value = $entity->get($key);

        if ($value !== null) {
            $value = $this->isJson($value) ? json_decode($value, true) : $value;

            // Remove elements that are not important for storage.
            foreach ($value as &$v) {
                unset($v['id']);
                unset($v['order']);
                unset($v['progress']);
                unset($v['element']);
            }
        }
        $entity->set($key, $value);

{'fraction_non_alphanumeric': 0.1519756838905775, 'fraction_numerical': 0.0, 'mean_word_length': 2.364565587734242, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '7136327', 'n_tokens_mistral': 586, 'n_tokens_neox': 580, 'n_words': 157}