<commit_before><?php

namespace Brera\PoC;

use Brera\PoC\Renderer\ProductRenderer;
use Brera\PoC\KeyValue\DataPoolWriter;
use Brera\PoC\Product\Product;

class PoCProductProjector
{
    /**
     * @var ProductRenderer[]
     */
    private $renderers;

    /**
     * @var DataPoolWriter
     */
    private $dataPoolWriter;

    /**
     * @param ProductRenderer[] $renderers
     * @param DataPoolWriter $dataPoolWriter
     */
    public function __construct($renderers, DataPoolWriter $dataPoolWriter)
    {
        $this->renderers = $renderers;
        $this->dataPoolWriter = $dataPoolWriter;
    }

    /**
     * @param Product $product
     */
    public function project(Product $product)
    {
	    foreach ($this->renderers as $renderer) {
		    // The projector renderer could be used even on the frontend.
		    // The renderer is decoupled from the data storage and display.
		    $html = $renderer->render($product);
		    $this->dataPoolWriter->setPoCProductHtml($product->getId(), $html);
	    }
    }
}<commit_msg>Issue #12: Add some TODOs and notes<commit_after><?php

namespace Brera\PoC;

use Brera\PoC\Renderer\ProductRenderer;
use Brera\PoC\KeyValue\DataPoolWriter;
use Brera\PoC\Product\Product;

class PoCProductProjector
{
	/* TODO: Replace array with RendererCollection */
    /**
     * @var ProductRenderer[]
     */
    private $renderers;

    /**
     * @var DataPoolWriter
     */
    private $dataPoolWriter;

    /**
     * @param ProductRenderer[] $renderers
     * @param DataPoolWriter $dataPoolWriter
     */
    public function __construct($renderers, DataPoolWriter $dataPoolWriter)
    {
        $this->renderers = $renderers;
        $this->dataPoolWriter = $dataPoolWriter;
    }

    /**
     * @param Product $product
     */
    public function project(Product $product)
    {
	    /* TODO: Looping is done inside of RendererCollection. Projector just calls render() on RendererCollection. */

	    foreach ($this->renderers as $renderer) {
		    // The projector renderer could be used even on the frontend.
		    // The renderer is decoupled from the data storage and display.

		    /* TODO: Make renderer return list of snippet outputs */

		    $html = $renderer->render($product);

		    /* TODO: Loop through returned results and put each to data pool */

		    $this->dataPoolWriter->setPoCProductHtml($product->getId(), $html);
	    }
    }
}

/**
 *
 * - Key generation goes from DataPoll writer to Snippet
 * - Then projector injects the list of snippets into DataPoolWriter
 * - And DataPool writer gets key and content from each snippet and puts it into key/value storage
 *
 */
{'fraction_non_alphanumeric': 0.1090496024233245, 'fraction_numerical': 0.0007572889057175312, 'mean_word_length': 2.834542815674891, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5973455', 'n_tokens_mistral': 798, 'n_tokens_neox': 756, 'n_words': 214}