<commit_before><?php
/*
 * This file is part of the Eko\FeedBundle Symfony bundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Eko\FeedBundle\Formatter;

use Eko\FeedBundle\Feed\Feed;
use Eko\FeedBundle\Item\Field;
use Eko\FeedBundle\Item\Writer\ItemInterface;

/**
 * Formatter
 *
 * This class provides formatter methods
 *
 * @author <NAME> <<EMAIL>>
 */
class Formatter
{
    /**
     * @var Feed $feed A feed instance
     */
    protected $feed;

    /**
     * @var DOMDocument $dom XML DOMDocument
     */
    protected $dom;

    /**
     * @var array $fields Contain Field instances for this formatter
     */
    protected $fields = array();

    /**
     * Construct a formatter with given feed
     *
     * @param Feed $feed A feed instance
     */
    public function __construct(Feed $feed)
    {
        $fields = $feed->getFields();

        if (!empty($fields)) {
            foreach ($fields as $field) {
                $this->fields[] = $field;
            }
        }

        $this->feed = $feed;
    }

    /**
     * Format field
     *
     * @param Field         $field A field instance
     * @param ItemInterface $item  An entity instance
     * 
     * @return string
     */
    protected function format(Field $field, ItemInterface $item)
    {
        $name = $field->getName();
<commit_msg>Refactor custom fields merging<commit_after><?php
/*
 * This file is part of the Eko\FeedBundle Symfony bundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Eko\FeedBundle\Formatter;

use Eko\FeedBundle\Feed\Feed;
use Eko\FeedBundle\Item\Field;
use Eko\FeedBundle\Item\Writer\ItemInterface;

/**
 * Formatter
 *
 * This class provides formatter methods
 *
 * @author <NAME> <<EMAIL>>
 */
class Formatter
{
    /**
     * @var Feed $feed A feed instance
     */
    protected $feed;

    /**
     * @var DOMDocument $dom XML DOMDocument
     */
    protected $dom;

    /**
     * @var array $fields Contain Field instances for this formatter
     */
    protected $fields = array();

    /**
     * Construct a formatter with given feed
     *
     * @param Feed $feed A feed instance
     */
    public function __construct(Feed $feed)
    {
        $this->fields = array_merge($this->fields, $feed->getFields());

        $this->feed = $feed;
    }

    /**
     * Format field
     *
     * @param Field         $field A field instance
     * @param ItemInterface $item  An entity instance
     * 
     * @return string
     */
    protected function format(Field $field, ItemInterface $item)
    {
        $name = $field->getName();

{'fraction_non_alphanumeric': 0.11927582534611289, 'fraction_numerical': 0.0, 'mean_word_length': 2.2767441860465114, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 24, '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': '5864400', 'n_tokens_mistral': 834, 'n_tokens_neox': 816, 'n_words': 256}